ProjectTest::checkFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 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