Completed
Push — master ( 74c3c7...591b88 )
by Eric
08:09
created

ArrayDataSourceTest::testInheritance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Grid\Tests\DataSource;
13
14
use Lug\Component\Grid\DataSource\ArrayDataSource;
15
use Lug\Component\Grid\DataSource\DataSourceInterface;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class ArrayDataSourceTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var ArrayDataSource
24
     */
25
    private $dataSource;
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function setUp()
31
    {
32
        $this->dataSource = new ArrayDataSource();
33
    }
34
35
    public function testInheritance()
36
    {
37
        $this->assertInstanceOf(DataSourceInterface::class, $this->dataSource);
38
    }
39
40
    public function testDefaultState()
41
    {
42
        $this->assertEmpty(iterator_to_array($this->dataSource));
43
        $this->assertCount(0, $this->dataSource);
44
    }
45
46
    public function testInitialState()
47
    {
48
        $this->dataSource = new ArrayDataSource($objects = [new \stdClass()]);
49
50
        $this->assertSame($objects, iterator_to_array($this->dataSource));
51
        $this->assertCount(count($objects), $this->dataSource);
52
    }
53
}
54