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

ClearableTraitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testClear() 0 7 1
A testIsEmpty() 0 6 1
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