@@ -19,19 +19,63 @@ class AbstractFontProcessorTest extends BaseTestCase
19
19
public function testTextBlock (): void
20
20
{
21
21
$ text = 'AAAA BBBB CCCC ' ;
22
- $ font = (new Font ($ this ->getTestResourcePath ('test.ttf ' )))->setWrapWidth (20 )->setSize (50 );
22
+ $ font = (new Font ($ this ->getTestResourcePath ('test.ttf ' )))
23
+ ->setWrapWidth (20 )
24
+ ->setSize (50 )
25
+ ->setLineHeight (1.25 )
26
+ ->setAlignment ('center ' );
27
+
23
28
$ processor = Mockery::mock (AbstractFontProcessor::class)->makePartial ();
24
- $ processor ->shouldReceive ('boxSize ' )->with ('T ' , $ font )->andReturn (new Rectangle (12 , 6 ));
25
- $ processor ->shouldReceive ('boxSize ' )->with ('Hy ' , $ font )->andReturn (new Rectangle (24 , 6 ));
26
- $ processor ->shouldReceive ('boxSize ' )->with ('AAAA ' , $ font )->andReturn (new Rectangle (24 , 6 ));
27
- $ processor ->shouldReceive ('boxSize ' )->with ('AAAA BBBB ' , $ font )->andReturn (new Rectangle (24 , 6 ));
28
- $ processor ->shouldReceive ('boxSize ' )->with ('BBBB ' , $ font )->andReturn (new Rectangle (24 , 6 ));
29
- $ processor ->shouldReceive ('boxSize ' )->with ('BBBB CCCC ' , $ font )->andReturn (new Rectangle (24 , 6 ));
30
- $ processor ->shouldReceive ('boxSize ' )->with ('CCCC ' , $ font )->andReturn (new Rectangle (24 , 6 ));
31
- $ processor ->shouldReceive ('boxSize ' )->with ($ text , $ font )->andReturn (new Rectangle (100 , 25 ));
29
+
30
+ $ processor
31
+ ->shouldReceive ('boxSize ' )
32
+ ->with ('T ' , $ font )
33
+ ->andReturn (new Rectangle (12 , 6 ));
34
+ $ processor
35
+ ->shouldReceive ('boxSize ' )
36
+ ->with ('Hy ' , $ font )
37
+ ->andReturn (new Rectangle (24 , 6 ));
38
+
39
+ $ processor
40
+ ->shouldReceive ('boxSize ' )
41
+ ->with ('AAAA ' , $ font )
42
+ ->andReturn (new Rectangle (24 , 6 , new Point (1000 , 0 )));
43
+
44
+ $ processor
45
+ ->shouldReceive ('boxSize ' )
46
+ ->with ('AAAA BBBB ' , $ font )
47
+ ->andReturn (new Rectangle (24 , 6 ));
48
+
49
+ $ processor
50
+ ->shouldReceive ('boxSize ' )
51
+ ->with ('BBBB ' , $ font )
52
+ ->andReturn (new Rectangle (24 , 6 , new Point (2000 , 0 )));
53
+
54
+ $ processor
55
+ ->shouldReceive ('boxSize ' )
56
+ ->with ('BBBB CCCC ' , $ font )
57
+ ->andReturn (new Rectangle (24 , 6 ));
58
+
59
+ $ processor
60
+ ->shouldReceive ('boxSize ' )
61
+ ->with ('CCCC ' , $ font )
62
+ ->andReturn (new Rectangle (24 , 6 , new Point (3000 , 0 )));
63
+
64
+ $ processor
65
+ ->shouldReceive ('boxSize ' )
66
+ ->with ($ text , $ font )
67
+ ->andReturn (new Rectangle (100 , 25 , new Point (10 , 0 )));
68
+
32
69
$ block = $ processor ->textBlock ($ text , $ font , new Point (0 , 0 ));
70
+
33
71
$ this ->assertInstanceOf (TextBlock::class, $ block );
34
72
$ this ->assertEquals (3 , $ block ->count ());
73
+ $ this ->assertEquals (-512 , $ block ->getAtPosition (0 )->position ()->x ());
74
+ $ this ->assertEquals (-16 , $ block ->getAtPosition (0 )->position ()->y ());
75
+ $ this ->assertEquals (-1012 , $ block ->getAtPosition (1 )->position ()->x ());
76
+ $ this ->assertEquals (-8 , $ block ->getAtPosition (1 )->position ()->y ());
77
+ $ this ->assertEquals (-1512 , $ block ->getAtPosition (2 )->position ()->x ());
78
+ $ this ->assertEquals (0 , $ block ->getAtPosition (2 )->position ()->y ());
35
79
}
36
80
37
81
public function testNativeFontSize (): void
0 commit comments