UsherTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLinearUsher() 0 21 1
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
use SixtyNine\DataTypes\Vector;
11
use PHPUnit\Framework\TestCase;
12
13
class UsherTest extends TestCase
14
{
15
    public function testLinearUsher()
16
    {
17
//        Logger::getInstance()
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
//            ->toConsole()
19
//            ->toFile('/tmp/my-log.log')
20
//        ;
21
22
        $factory = FontsFactory::create(__DIR__ . '/../fixtures/fonts');
23
        $metrics = new FontMetrics($factory);
24
        $placer = PlacerFactory::getInstance()->getPlacer(PlacerFactory::PLACER_LINEAR_H, 800, 600, 5);
25
        $usher = new Usher(800, 600, $placer, $metrics);
26
        $place1 = $usher->getPlace('foobar', 'Arial.ttf', 12, 0);
27
        // Assert the first word is positioned at (0,0)
28
        $this->assertEquals(new Vector(0, 0), $place1->getPosition());
29
30
        $place2 = $usher->getPlace('foobar', 'Arial.ttf', 12, 270);
31
        // Assert the second word is placed on the right of the first word
32
        $this->assertTrue($place1->getWidth() <= $place2->getX(),
33
            sprintf('Expected %s to be smaller or equals than %s', $place1->getWidth(), $place2->getX())
34
        );
35
    }
36
}
37