1 | <?php |
||
25 | abstract class PHPUnit_Stakx_TestCase extends \PHPUnit_Framework_TestCase |
||
|
|||
26 | { |
||
27 | const FM_OBJ_TEMPLATE = "---\n%s\n---\n\n%s"; |
||
28 | |||
29 | /** @var string */ |
||
30 | protected $assetFolder; |
||
31 | /** @var vfsStreamFile */ |
||
32 | protected $dummyFile; |
||
33 | /** @var vfsStreamDirectory */ |
||
34 | protected $rootDir; |
||
35 | /** @var Filesystem */ |
||
36 | protected $fs; |
||
37 | |||
38 | public function setUp() |
||
52 | |||
53 | public function tearDown() |
||
60 | |||
61 | /// |
||
62 | // Assertion functions |
||
63 | /// |
||
64 | |||
65 | /** |
||
66 | * @param string $needle |
||
67 | * @param string $haystack |
||
68 | * @param string $message |
||
69 | */ |
||
70 | protected function assertStringContains($needle, $haystack, $message = '') |
||
74 | |||
75 | protected function assertFileContains($fileContent, $filePath, $message = '') |
||
83 | |||
84 | /// |
||
85 | // Utility Functions |
||
86 | /// |
||
87 | |||
88 | protected function bookCollectionProvider($jailed = false) |
||
101 | |||
102 | /** |
||
103 | * Write a temporary file to the asset folder. |
||
104 | * |
||
105 | * This file will be written to the actual filesystem and not the virtual filesystem. |
||
106 | * |
||
107 | * @param $fileName |
||
108 | * @param $content |
||
109 | * |
||
110 | * @return string Path to the temporary file; relative to the project's root |
||
111 | */ |
||
112 | protected function createTempFile($fileName, $content) |
||
119 | |||
120 | /** |
||
121 | * Create a blank file on the virtual filesystem. |
||
122 | * |
||
123 | * @param string $filename |
||
124 | * @param string $classType |
||
125 | * @param string $content |
||
126 | * |
||
127 | * @return mixed |
||
128 | */ |
||
129 | protected function createBlankFile($filename, $classType, $content) |
||
140 | |||
141 | /** |
||
142 | * Create a virtual file following the a FrontMatter-ready template. |
||
143 | * |
||
144 | * @param string $classType |
||
145 | * @param array $frontMatter |
||
146 | * @param string $body |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | protected function createVirtualFrontMatterFile($classType, $frontMatter = array(), $body = 'Body Text') |
||
154 | |||
155 | /** |
||
156 | * Set the contents of our default virtual file and create a File object for it. |
||
157 | * |
||
158 | * @param array $frontMatter |
||
159 | * @param string $body |
||
160 | * |
||
161 | * @return File |
||
162 | */ |
||
163 | protected function setAndCreateVirtualFrontMatterFileObject($frontMatter = array(), $body = 'Body Text') |
||
171 | |||
172 | /** |
||
173 | * Create multiple virtual files from a given array of information. |
||
174 | * |
||
175 | * @param string $classType |
||
176 | * @param array $elements |
||
177 | * |
||
178 | * @return array |
||
179 | */ |
||
180 | protected function createMultipleVirtualFiles($classType, $elements) |
||
202 | |||
203 | /** |
||
204 | * Create a File object from a given path. |
||
205 | * |
||
206 | * @param string $filePath |
||
207 | * |
||
208 | * @return File |
||
209 | */ |
||
210 | protected function createFileObjectFromPath($filePath) |
||
218 | |||
219 | /** |
||
220 | * Generate a FrontMatter-ready syntax to be used as a file's content. |
||
221 | * |
||
222 | * @param array $frontMatter |
||
223 | * @param string $body |
||
224 | * |
||
225 | * @return string |
||
226 | */ |
||
227 | protected function buildFrontMatterTemplate(array $frontMatter = array(), $body = 'Body text') |
||
233 | |||
234 | /** |
||
235 | * Get a mock logger. |
||
236 | * |
||
237 | * @return LoggerInterface |
||
238 | */ |
||
239 | protected function getMockLogger() |
||
243 | |||
244 | /** |
||
245 | * Get a real logger instance that will save output to the console. |
||
246 | * |
||
247 | * @return StakxLogger |
||
248 | */ |
||
249 | protected function getReadableLogger() |
||
257 | |||
258 | /** |
||
259 | * Create a temporary folder where temporary file writes will be made to. |
||
260 | * |
||
261 | * @param string $folderName |
||
262 | */ |
||
263 | protected function createAssetFolder($folderName) |
||
269 | } |
||
270 |
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
.