Completed
Push — master ( 0631c4...d19571 )
by Andrii
02:04
created

ProjectTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 3
c 3
b 0
f 2
lcom 0
cbo 2
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCount() 0 6 1
A testFindByName() 0 5 1
A checkFound() 0 7 1
1
<?php
2
/**
3
 * Libraries.io API implementation for yii2-hiart.
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart-librariesio
6
 * @package   yii2-hiart-librariesio
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\librariesio\tests\functional;
12
13
use hiqdev\hiart\librariesio\models\Project;
14
15
class ProjectTest extends \PHPUnit\Framework\TestCase
16
{
17
    public function testCount()
18
    {
19
        $total = Project::find()->where(['q' => 'jquery'])->count();
20
21
        $this->assertGreaterThan(1, $total);
22
    }
23
24
    public function testFindByName()
25
    {
26
        $query = Project::find()->where(['q' => 'jquery'])->limit(2);
27
        $this->checkFound($query);
28
    }
29
30
    public function checkFound($query)
31
    {
32
        $models = $query->all();
33
34
        $this->assertSame(2, count($models));
35
        $this->assertInstanceOf(Project::class, reset($models));
36
    }
37
}
38