Completed
Branch release/v1.0.0 (b932d7)
by Edward
03:07 queued 40s
created

ClearableTraitTest::testClear()   A

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
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * File ClearableTraitTest.php
4
 *
5
 * @author Edward Pfremmer <[email protected]>
6
 */
7
namespace Epfremme\Tests\Collection\Traits;
8
9
use Epfremme\Collection\Collection;
10
11
/**
12
 * Class ClearableTraitTest
13
 *
14
 * @package Epfremme\Tests\Collection\Traits
15
 */
16
class ClearableTraitTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @var Collection
20
     */
21
    private $collection;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function setUp()
27
    {
28
        parent::setUp();
29
30
        $this->collection = new Collection([1, 2, 3, 'a' => 4, 'b' => 5]);
31
    }
32
33
    /**
34
     * Test emptying collection
35
     *
36
     * @return void
37
     */
38
    public function testClear()
39
    {
40
        $this->collection->clear();
41
42
        $this->assertAttributeEmpty('elements', $this->collection);
43
        $this->assertAttributeCount(0, 'elements', $this->collection);
44
    }
45
46
    /**
47
     * Test collection empty method
48
     *
49
     * @return void
50
     */
51
    public function testIsEmpty()
52
    {
53
        $this->assertFalse($this->collection->isEmpty());
54
        $this->collection->clear();
55
        $this->assertTrue($this->collection->isEmpty());
56
    }
57
}
58