Completed
Push — master ( 875476...1855ce )
by Dan
02:56
created

FontMetricsTest::testMetricsHorizontal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace SixtyNine\Cloud\Tests\Builder;
4
5
use SixtyNine\Cloud\Factory\FontsFactory;
6
use SixtyNine\Cloud\FontMetrics;
7
8
class FontMetricsTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testMetricsHorizontal()
11
    {
12
        $factory = FontsFactory::create(__DIR__ . '/fixtures/fonts');
13
        $calc = new FontMetrics($factory);
14
15
        $size1 = $calc->calculateSize('abc', 'Arial.ttf', 10);
16
        $size2 = $calc->calculateSize('abc', 'Arial.ttf', 12);
17
        $size3 = $calc->calculateSize('abc', 'Arial.ttf', 1);
18
        $size4 = $calc->calculateSize('a', 'Arial.ttf', 1);
19
20
        $this->assertTrue($size1->getWidth() < $size2->getWidth());
21
        $this->assertTrue($size1->getHeight() < $size2->getHeight());
22
        $this->assertTrue($size3->getWidth() < $size1->getWidth());
23
        $this->assertTrue($size3->getHeight() < $size1->getHeight());
24
        $this->assertTrue($size4->getWidth() < $size3->getWidth());
25
        $this->assertEquals($size4->getHeight(),  $size3->getHeight());
26
    }
27
28
    public function testMetricsVertical()
29
    {
30
        $factory = FontsFactory::create(__DIR__ . '/fixtures/fonts');
31
        $calc = new FontMetrics($factory);
32
33
        $size1 = $calc->calculateSize('abc', 'Arial.ttf', 10, 270);
34
        $size2 = $calc->calculateSize('abc', 'Arial.ttf', 12, 270);
35
        $size3 = $calc->calculateSize('abc', 'Arial.ttf', 1, 270);
36
        $size4 = $calc->calculateSize('a', 'Arial.ttf', 1, 270);
37
38
        $this->assertTrue($size1->getWidth() < $size2->getWidth());
39
        $this->assertTrue($size1->getHeight() < $size2->getHeight());
40
        $this->assertTrue($size3->getWidth() < $size1->getWidth());
41
        $this->assertTrue($size3->getHeight() < $size1->getHeight());
42
        $this->assertEquals($size4->getWidth(), $size3->getWidth());
43
        $this->assertTrue($size4->getHeight() <  $size3->getHeight());
44
    }
45
}
46