1 | <?php |
||
23 | abstract class PHPUnit_Stakx_TestCase extends \PHPUnit_Framework_TestCase |
||
|
|||
24 | { |
||
25 | const FM_OBJ_TEMPLATE = "---\n%s\n---\n\n%s"; |
||
26 | |||
27 | /** @var string */ |
||
28 | protected $assetFolder; |
||
29 | |||
30 | /** |
||
31 | * @var vfsStreamFile |
||
32 | */ |
||
33 | protected $dummyFile; |
||
34 | |||
35 | /** |
||
36 | * @var vfsStreamDirectory |
||
37 | */ |
||
38 | protected $rootDir; |
||
39 | |||
40 | /** |
||
41 | * @var Filesystem |
||
42 | */ |
||
43 | protected $fs; |
||
44 | |||
45 | public function setUp() |
||
57 | |||
58 | /// |
||
59 | // Assertion functions |
||
60 | /// |
||
61 | |||
62 | /** |
||
63 | * @param string $haystack |
||
64 | */ |
||
65 | protected function assertStringContains($needle, $haystack, $message = '') |
||
69 | |||
70 | protected function assertFileContains($fileContent, $filePath, $message = '') |
||
78 | |||
79 | /// |
||
80 | // Utility Functions |
||
81 | /// |
||
82 | |||
83 | protected function bookCollectionProvider($jailed = false) |
||
96 | |||
97 | /** |
||
98 | * Write a temporary file to the asset folder |
||
99 | * |
||
100 | * @param $fileName |
||
101 | * @param $content |
||
102 | * |
||
103 | * @return string Path to the temporary file; relative to the project's root |
||
104 | */ |
||
105 | protected function createTempFile($fileName, $content) |
||
112 | |||
113 | protected function createBlankFile($filename, $classType, $content) |
||
122 | |||
123 | protected function createVirtualFilePath($frontMatter = array(), $body = 'Body Text') |
||
131 | |||
132 | /** |
||
133 | * @param string $classType |
||
134 | * @param array $frontMatter |
||
135 | * @param string $body |
||
136 | * |
||
137 | * @return mixed |
||
138 | */ |
||
139 | protected function createVirtualFile($classType, $frontMatter = array(), $body = 'Body Text') |
||
143 | |||
144 | protected function createMultipleVirtualFiles($classType, $elements) |
||
164 | |||
165 | /** |
||
166 | * Get a mock logger. |
||
167 | * |
||
168 | * @return LoggerInterface |
||
169 | */ |
||
170 | protected function getMockLogger() |
||
174 | |||
175 | /** |
||
176 | * Get a real logger instance that will save output to the console. |
||
177 | * |
||
178 | * @return StakxLogger |
||
179 | */ |
||
180 | protected function getReadableLogger() |
||
188 | |||
189 | /** |
||
190 | * Generate a FrontMatter-ready syntax to be used as a file's content. |
||
191 | * |
||
192 | * @param array $frontMatter |
||
193 | * @param string $body |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | protected function generateFM(array $frontMatter = array(), $body = 'Body text') |
||
203 | |||
204 | /** |
||
205 | * Create a temporary folder where temporary file writes will be made to |
||
206 | * |
||
207 | * Remember to remove the folder in during the ::tearDown() |
||
208 | * |
||
209 | * @param string $folderName |
||
210 | */ |
||
211 | protected function createAssetFolder($folderName) |
||
217 | } |
||
218 |
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider
.