Completed
Push — master ( ed48d3...e52a1e )
by Daniel
02:16
created

JobCollectionTest::testPickThrowsLengthExceptionOnInvalidPosition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
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 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Jobles\Tests\Core\Job;
4
5
use Jobles\Core\Job\Job;
6
use Jobles\Core\Job\JobCollection;
7
use Jobles\Core\Job\JobIterator;
8
9
class JobCollectionTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var JobCollection
13
     */
14
    private $collection;
15
16
    public function setUp()
17
    {
18
        $this->collection = new JobCollection;
19
    }
20
21
    public function testAddJobPushJobIntoJobsArray()
22
    {
23
        $job = new Job;
24
        $this->collection->addJob($job);
25
26
        $this->assertAttributeContains($job, 'jobs', $this->collection);
27
    }
28
29
    public function testAddJobIncrementsSizeAttribute()
30
    {
31
        $job = new Job;
32
        $this->collection->addJob($job);
33
34
        $this->assertAttributeEquals(1, 'size', $this->collection);
35
    }
36
37
    public function testPickRetrievesExpectedJob()
38
    {
39
        $job = new Job;
40
        $this->collection->addJob($job);
41
42
        $this->assertEquals($job, $this->collection->pick(0));
43
    }
44
45
    public function testPickThrowsLengthExceptionOnInvalidPosition()
46
    {
47
        $this->expectException(\LengthException::class);
48
        $this->expectExceptionMessage('Invalid job position: 0');
49
        $this->collection->pick(0);
50
    }
51
52
    public function testCountReturnsCorrectSize()
53
    {
54
        $this->assertEquals(0, $this->collection->count());
55
56
        $job = new Job;
57
        $this->collection->addJob($job);
58
59
        $this->assertEquals(1, $this->collection->count());
60
    }
61
62
    public function testGetIteratorForJobCollection()
63
    {
64
        $this->assertInstanceOf(JobIterator::class, $this->collection->getIterator());
65
    }
66
}
67