1
1
<?php
2
+ declare (strict_types=1 );
3
+
2
4
/**
3
5
* @section LICENSE
4
6
* This file is created by vianetz <[email protected] >.
25
27
26
28
final class PdfTest extends TestCase
27
29
{
28
- /**
29
- * @return \Vianetz\Pdf\Model\Document
30
- */
31
- private function getDocumentMock ()
30
+ private function getDocumentMock (): \Vianetz \Pdf \Model \Document
32
31
{
33
32
/** @var \Vianetz\Pdf\Model\Document $document */
34
33
$ document = new \Vianetz \Pdf \Model \Document ();
35
- $ document ->setHtmlContents ('<html>test</html> ' );
34
+ $ document ->setHtmlContents ('<html><body>This is the <strong>pdf-generator</strong> test!</body> </html> ' );
36
35
37
36
return $ document ;
38
37
}
39
38
40
- /**
41
- * @return \Vianetz\Pdf\Model\Pdf
42
- */
43
- private function getPdfMock (Config $ config = null )
39
+ private function getPdfMock (?Config $ config = null ): \Vianetz \Pdf \Model \Pdf
44
40
{
45
41
return PdfFactory::general ()->create ($ config );
46
42
}
47
43
48
- /**
49
- * @return void
50
- */
51
- public function tearDown ()
44
+ public function tearDown (): void
52
45
{
53
46
parent ::tearDown ();
54
47
@@ -57,21 +50,15 @@ public function tearDown()
57
50
@rmdir ('./tmp/ ' );
58
51
}
59
52
60
- /**
61
- * @return void
62
- */
63
- public function testAddOneDocumentIncreasesDocumentCounterByOne ()
53
+ public function testAddOneDocumentIncreasesDocumentCounterByOne (): void
64
54
{
65
55
$ pdfMock = $ this ->getPdfMock ();
66
56
$ pdfMock ->addDocument ($ this ->getDocumentMock ());
67
57
68
58
$ this ->assertEquals (1 , $ pdfMock ->countDocuments ());
69
59
}
70
60
71
- /**
72
- * @return void
73
- */
74
- public function testAddThreeDocumentsIncreasesDocumentCounterByThree ()
61
+ public function testAddThreeDocumentsIncreasesDocumentCounterByThree (): void
75
62
{
76
63
$ pdfMock = $ this ->getPdfMock ();
77
64
$ pdfMock ->addDocument ($ this ->getDocumentMock ())
@@ -81,30 +68,21 @@ public function testAddThreeDocumentsIncreasesDocumentCounterByThree()
81
68
$ this ->assertEquals (3 , $ pdfMock ->countDocuments ());
82
69
}
83
70
84
- /**
85
- * @return void
86
- */
87
- public function testGetContentsReturnsExceptionIfNoDocumentsAdded ()
71
+ public function testGetContentsReturnsExceptionIfNoDocumentsAdded (): void
88
72
{
89
73
$ this ->expectException (NoDataException::class);
90
74
$ this ->getPdfMock ()->getContents ();
91
75
}
92
76
93
- /**
94
- * @return void
95
- */
96
- public function testGetContentsReturnsExpectedResult ()
77
+ public function testGetContentsReturnsNonEmptyResult (): void
97
78
{
98
79
$ pdfMock = $ this ->getPdfMock ();
99
80
$ pdfMock ->addDocument ($ this ->getDocumentMock ());
100
81
101
82
$ this ->assertNotEmpty ($ pdfMock ->getContents ());
102
83
}
103
84
104
- /**
105
- * @return void
106
- */
107
- public function testDebugModeGeneratesDebugFile ()
85
+ public function testDebugModeGeneratesDebugFile (): void
108
86
{
109
87
$ config = new Config ();
110
88
$ config ->setIsDebugMode (true )
@@ -116,20 +94,14 @@ public function testDebugModeGeneratesDebugFile()
116
94
$ this ->assertFileExists (AbstractGenerator::DEBUG_FILE_NAME );
117
95
}
118
96
119
- /**
120
- * @return void
121
- */
122
- public function testConfigTempDirMayNotBeNull ()
97
+ public function testConfigTempDirMayNotBeNull (): void
123
98
{
124
99
$ config = new Config ();
125
100
126
101
$ this ->assertNotEmpty ($ config ->getTempDir ());
127
102
}
128
103
129
- /**
130
- * @return void
131
- */
132
- public function testNoExceptionIfTempDirNotWritable ()
104
+ public function testNoExceptionIfTempDirNotWritable (): void
133
105
{
134
106
@mkdir ('./tmp ' , 0000 );
135
107
@@ -140,6 +112,6 @@ public function testNoExceptionIfTempDirNotWritable()
140
112
$ pdfMock ->addDocument ($ this ->getDocumentMock ())
141
113
->render ();
142
114
143
- $ this ->assertDirectoryNotIsWritable ('tmp/ ' );
115
+ $ this ->assertDirectoryIsNotWritable ('tmp/ ' );
144
116
}
145
117
}
0 commit comments