forked from Intervention/image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationTest.php
More file actions
88 lines (76 loc) · 2.45 KB
/
AnimationTest.php
File metadata and controls
88 lines (76 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
use Intervention\Image\Animation;
class AnimationTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testConstructor()
{
$animation = new Animation;
$this->assertInstanceOf('Intervention\Image\Animation', $animation);
$this->assertNull($animation->loops);
}
public function testConstructorWithParameters()
{
$animation = new Animation(12);
$this->assertInstanceOf('Intervention\Image\Animation', $animation);
$this->assertEquals(12, $animation->loops);
}
public function testIterate()
{
$frame = Mockery::mock('Intervention\Image\Frame');
$animation = new Animation;
$animation->addFrame($frame);
$animation->addFrame($frame);
$animation->addFrame($frame);
$counter = 0;
foreach ($animation as $frame) {
$counter++;
}
$this->assertEquals(3, $counter);
}
public function testSetLoops()
{
$animation = new Animation(12);
$animation->setLoops(13);
$this->assertEquals(13, $animation->loops);
}
public function testAddFrame()
{
$frame = Mockery::mock('Intervention\Image\Frame');
$animation = new Animation;
$animation->addFrame($frame);
$this->assertHasFrames(1, $animation);
$animation->addFrame($frame);
$this->assertHasFrames(2, $animation);
}
public function testAddFrames()
{
$frame = Mockery::mock('Intervention\Image\Frame');
$animation = new Animation;
$animation->addFrames(array($frame, $frame));
$this->assertHasFrames(2, $animation);
$animation->addFrames(array($frame, $frame, $frame));
$this->assertHasFrames(5, $animation);
$animation->addFrames(array($frame, $frame));
$this->assertHasFrames(7, $animation);
}
public function testSetFrames()
{
$frame = Mockery::mock('Intervention\Image\Frame');
$animation = new Animation;
$animation->setFrames(array($frame, $frame, $frame));
$this->assertHasFrames(3, $animation);
}
public function testGetFrames()
{
$animation = new Animation;
$this->assertEquals(array(), $animation->getFrames());
}
private function assertHasFrames($number, $animation)
{
$this->assertEquals($number, count($animation->getFrames()));
}
}