Test Failed
Push — master ( 3feb07...e3c021 )
by Dan
10:26
created

UsherTest::testLinearUsher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace SixtyNine\Cloud\Tests\Usher;
4
5
use Imagine\Image\Point;
6
use SixtyNine\Cloud\Factory\FontsFactory;
7
use SixtyNine\Cloud\Factory\PlacerFactory;
8
use SixtyNine\Cloud\FontMetrics;
9
use SixtyNine\Cloud\Usher\Usher;
10
11
class UsherTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function testLinearUsher()
14
    {
15
        $factory = FontsFactory::create(__DIR__ . '/../fixtures/fonts');
16
        $metrics = new FontMetrics($factory);
17
        $placer = PlacerFactory::getInstance()->getPlacer(PlacerFactory::PLACER_LINEAR_H, 800, 600, 5);
18
        $usher = new Usher(800, 600, $placer, $metrics);
19
        $place1 = $usher->getPlace('foobar', 'Arial.ttf', 12, 0);
20
        // Assert the first word is positioned at (0,0)
21
        $this->assertEquals(new Point(0, 0), $place1->getPosition());
22
23
        $place2 = $usher->getPlace('foobar', 'Arial.ttf', 12, 90);
24
        // Assert the second word is placed on the right of the first word
25
        $this->assertEquals(0, $place2->getY());
26
        $this->assertTrue($place1->getWidth() <= $place2->getX());
27
    }
28
}
29