├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── bin └── updateMissingStubClasses ├── classes ├── atoum.php ├── atoum │ ├── mock │ │ └── stream.php │ └── test.php └── mageekguy │ ├── atoum.php │ └── atoum │ └── stubs │ ├── asserters.php │ └── asserters │ ├── adapter.php │ ├── asserter.php │ ├── boolean.php │ ├── castToArray.php │ ├── castToString.php │ ├── constant.php │ ├── dateInterval.php │ ├── dateTime.php │ ├── error.php │ ├── exception.php │ ├── extension.php │ ├── generator.php │ ├── hash.php │ ├── integer.php │ ├── iterator.php │ ├── mock.php │ ├── mysqlDateTime.php │ ├── output.php │ ├── phpArray.php │ ├── phpClass.php │ ├── phpFloat.php │ ├── phpFunction.php │ ├── phpObject.php │ ├── phpResource.php │ ├── phpString.php │ ├── sizeOf.php │ ├── stream.php │ ├── testedClass.php │ ├── utf8String.php │ └── variable.php ├── composer.json ├── demo.gif └── src ├── asserters.php └── functions.php /.gitattributes: -------------------------------------------------------------------------------- 1 | bin/updateDoc export-ignore 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | vendor/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2016, atoum contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * The name of atoum contributors may not be used to endorse or promote 13 | products derived from this software without specific prior written 14 | permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY ATOUM CONTIRBUTORS ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL ATOUM CONTIRBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # atoum stubs 2 | 3 | ![atoum](http://atoum.org/images/logo/atoum.png) 4 | 5 | ## Install it 6 | 7 | Install extension using [composer](https://getcomposer.org): 8 | 9 | ```json 10 | { 11 | "require-dev": { 12 | "atoum/stubs": "*" 13 | } 14 | } 15 | ``` 16 | 17 | ## Use it 18 | 19 | Once your IDE is correctly configured, the only thing you will have to do is use atoum 20 | through one of its alias: 21 | 22 | ```php 23 | Why are the PHPdoc annotations part of an external repository? 50 | 51 | Because we just don't want them in the middle of atoum's source code. It's not really useful there and it adds extra 52 | noise. 53 | 54 | Moreover, if we use PHPDoc for the userland API we should also add annotations to every method of the internal API. Too 55 | much work for a small amount of added value. 56 | 57 | > Why are those annotations only working on atoum aliases? 58 | 59 | Because we stored annotated code in an external repository, we would have to duplicate some classes to annotate them. 60 | Doing so would create duplicate classes and some IDEs will emit warnings. 61 | 62 | We don't want to add extra noise while providing a good code-completion. 63 | 64 | > Why not annotating every public method? 65 | 66 | Because they are not all meaningful in a test context. When you write unit tests with atoum, you will likely never call 67 | internal asserters' methods, even if they are public. They provide support for atoum so it can do its job well. But they 68 | won't help you in your everyday work. 69 | 70 | ## Upgrade stubs 71 | 72 | ``` 73 | bin/updateMissingStubClasses 74 | bin/updateDoc 75 | ``` 76 | 77 | This will only update existing methods. To add new method you will require to do it manually! 78 | Think also to look at the tree of [asserters](http://docs.atoum.org/en/latest/asserters.html) to extends 79 | the class properly. 80 | 81 | You probably also need to update `classes/mageekguy/atoum/stubs/asserters.php` with the new asserter set. 82 | 83 | ## License 84 | 85 | atoum stubs are released under the BSD-3-Clause License. See the bundled LICENSE file for details. -------------------------------------------------------------------------------- /bin/updateMissingStubClasses: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | $assertersInPath) 24 | { 25 | foreach ($assertersInPath as $asserter) 26 | { 27 | $asserterClasses[] = $asserter; 28 | } 29 | } 30 | 31 | $missing = array(); 32 | foreach ($iterator as $file) 33 | { 34 | if (!$file->isFile()) 35 | { 36 | continue; 37 | } 38 | 39 | if (!in_array($file->getFilename(), $asserterClasses)) 40 | { 41 | $missing[] = $file->getFilename(); 42 | } 43 | } 44 | 45 | // build missing classes 46 | foreach ($missing as $missingAsserterClass) 47 | { 48 | $path = createNewStubClass(str_replace('.php', '', $missingAsserterClass), 'mageekguy\\atoum\\stubs\\asserters'); 49 | echo 'Edit file at "', $path, '". Don\'t forget to update src/asserters.php', PHP_EOL; 50 | } 51 | 52 | echo 'Ended \o/'; 53 | -------------------------------------------------------------------------------- /classes/atoum.php: -------------------------------------------------------------------------------- 1 | given($mock = new \mock\MyFirstClass) 20 | * ->and($object = new MySecondClass($mock)) 21 | * 22 | * ->if($object->methodThatCallMyMethod()) // This will call myMethod from $mock 23 | * ->then 24 | * 25 | * ->mock($mock) 26 | * ->call('myMethod') 27 | * ->once() 28 | * ; 29 | * 30 | * @param string $function 31 | * 32 | * @return $this 33 | */ 34 | public function call($function) {} 35 | 36 | /** 37 | * "before" checks if the method has been called before the one passed as 38 | * parameter. 39 | * 40 | * when($mock = new \mock\example) 43 | * ->if( 44 | * $mock->test(), 45 | * $mock->test2() 46 | * ) 47 | * ->mock($mock) 48 | * ->call('test') 49 | * ->before($this->mock($mock)->call('test2')->once()) 50 | * ->once() // passes 51 | * ; 52 | * 53 | * $this 54 | * ->when($mock = new \mock\example) 55 | * ->if( 56 | * $mock->test2(), 57 | * $mock->test() 58 | * ) 59 | * ->mock($mock) 60 | * ->call('test') 61 | * ->before($this->mock($mock)->call('test2')->once()) 62 | * ->once() // fails 63 | * ; 64 | * 65 | * @param adapter $call 66 | * 67 | * @return $this 68 | */ 69 | public function before(self $call) {} 70 | 71 | /** 72 | * "after" checks if the method has been called after the one passed as 73 | * parameter. 74 | * 75 | * when($mock = new \mock\example) 78 | * ->if( 79 | * $mock->test2(), 80 | * $mock->test() 81 | * ) 82 | * ->mock($mock) 83 | * ->call('test') 84 | * ->after($this->mock($mock)->call('test2')->once()) 85 | * ->once() // passes 86 | * ; 87 | * 88 | * $this 89 | * ->when($mock = new \mock\example) 90 | * ->if( 91 | * $mock->test(), 92 | * $mock->test2() 93 | * ) 94 | * ->mock($mock) 95 | * ->call('test') 96 | * ->after($this->mock($mock)->call('test2')->once()) 97 | * ->once() // fails 98 | * ; 99 | * 100 | * @param adapter $call 101 | * 102 | * @return $this 103 | */ 104 | public function after(self $call) {} 105 | 106 | /** 107 | * This asserters check that the tested method (see call) from the tested 108 | * mock has been called exactly: 109 | * 110 | * * once 111 | * 112 | * * twice 113 | * 114 | * * thrice 115 | * 116 | * object(new MySecondClass($mock)) 121 | * 122 | * ->mock($mock) 123 | * ->call('myMethod') 124 | * ->once() 125 | * ->call('mySecondMethod') 126 | * ->twice() 127 | * ->call('myThirdMethod') 128 | * ->thrice() 129 | * ; 130 | * 131 | * Note: "once", "twice" and "thrice" are respectively equivalent to 132 | * exactly(1), exactly(2) and exactly(3). 133 | * 134 | * @param string $failMessage 135 | * 136 | * @return $this 137 | */ 138 | public function once($failMessage = null) {} 139 | 140 | /** 141 | * This asserters check that the tested method (see call) from the tested 142 | * mock has been called exactly: 143 | * 144 | * * once 145 | * 146 | * * twice 147 | * 148 | * * thrice 149 | * 150 | * object(new MySecondClass($mock)) 155 | * 156 | * ->mock($mock) 157 | * ->call('myMethod') 158 | * ->once() 159 | * ->call('mySecondMethod') 160 | * ->twice() 161 | * ->call('myThirdMethod') 162 | * ->thrice() 163 | * ; 164 | * 165 | * Note: "once", "twice" and "thrice" are respectively equivalent to 166 | * exactly(1), exactly(2) and exactly(3). 167 | * 168 | * @param string $failMessage 169 | * 170 | * @return $this 171 | */ 172 | public function twice($failMessage = null) {} 173 | 174 | /** 175 | * This asserters check that the tested method (see call) from the tested 176 | * mock has been called exactly: 177 | * 178 | * * once 179 | * 180 | * * twice 181 | * 182 | * * thrice 183 | * 184 | * object(new MySecondClass($mock)) 189 | * 190 | * ->mock($mock) 191 | * ->call('myMethod') 192 | * ->once() 193 | * ->call('mySecondMethod') 194 | * ->twice() 195 | * ->call('myThirdMethod') 196 | * ->thrice() 197 | * ; 198 | * 199 | * Note: "once", "twice" and "thrice" are respectively equivalent to 200 | * exactly(1), exactly(2) and exactly(3). 201 | * 202 | * @param string $failMessage 203 | * 204 | * @return $this 205 | */ 206 | public function thrice($failMessage = null) {} 207 | 208 | /** 209 | * "atLeastOnce" check that the tested method (see call) from the mock 210 | * has been called at least once. 211 | * 212 | * object(new MySecondClass($mock)) 217 | * 218 | * ->mock($mock) 219 | * ->call('myMethod') 220 | * ->atLeastOnce() 221 | * ; 222 | * 223 | * @param string $failMessage 224 | * 225 | * @return $this 226 | */ 227 | public function atLeastOnce($failMessage = null) {} 228 | 229 | /** 230 | * "exactly" check that the tested method (see call) has been called a 231 | * specific number of times. 232 | * 233 | * object(new MySecondClass($mock)) 238 | * 239 | * ->mock($mock) 240 | * ->call('myMethod') 241 | * ->exactly(2) 242 | * ; 243 | * 244 | * Note: You can have a simplified version with "->{2}". 245 | * 246 | * @param integer $number 247 | * @param string $failMessage 248 | * 249 | * @return $this 250 | */ 251 | public function exactly($number, $failMessage = null) {} 252 | 253 | /** 254 | * "never" check that the tested method (see call) has never been called. 255 | * 256 | * object(new MySecondClass($mock)) 261 | * 262 | * ->mock($mock) 263 | * ->call('myMethod') 264 | * ->never() 265 | * ; 266 | * 267 | * Note: "never" is equivalent to exactly(0). 268 | * 269 | * @param string $failMessage 270 | * 271 | * @return $this 272 | */ 273 | public function never($failMessage = null) {} 274 | 275 | /** 276 | * "withArguments" let you specify the expected arguments that the tested 277 | * method should receive when called (see call). 278 | * 279 | * object(new MySecondClass($mock)) 284 | * 285 | * ->mock($mock) 286 | * ->call('myMethod') 287 | * ->withArguments('first', 'second')->once() 288 | * ; 289 | * 290 | * also want to check the type, use withIdenticalArguments. 291 | * 292 | * @param mixed ...$arguments 293 | * 294 | * @return $this 295 | */ 296 | public function withArguments(...$arguments) {} 297 | 298 | /** 299 | * "withIdenticalArguments" let you specify the expected typed arguments 300 | * that tested method should receive when called (see call). 301 | * 302 | * object(new MySecondClass($mock)) 307 | * 308 | * ->mock($mock) 309 | * ->call('myMethod') 310 | * ->withIdenticalArguments('first', 'second')->once() 311 | * ; 312 | * 313 | * If you do not want to check the type, use withArguments. 314 | * 315 | * @param mixed ...$arguments 316 | * 317 | * @return $this 318 | */ 319 | public function withIdenticalArguments(...$arguments) {} 320 | 321 | /** 322 | * "withAtLeastArguments" let you specify the minimum expected arguments 323 | * that tested method should receive when called (see call). 324 | * 325 | * if($mock = new \mock\example) 328 | * ->and($mock->test('a', 'b')) 329 | * ->mock($mock) 330 | * ->call('test') 331 | * ->withAtLeastArguments(array('a'))->once() //passes 332 | * ->withAtLeastArguments(array('a', 'b'))->once() //passes 333 | * ->withAtLeastArguments(array('c'))->once() //fails 334 | * ; 335 | * 336 | * If you also want to check the type, use 337 | * withAtLeastIdenticalArguments. 338 | * 339 | * @param mixed[] $arguments 340 | * 341 | * @return $this 342 | */ 343 | public function withAtLeastArguments(array $arguments) {} 344 | 345 | /** 346 | * "withAtLeastIdenticalArguments" let you specify the minimum expected 347 | * typed arguments that tested method should receive when called (see 348 | * call). 349 | * 350 | * if($mock = new \mock\example) 353 | * ->and($mock->test(1, 2)) 354 | * ->mock($mock) 355 | * ->call('test') 356 | * ->withAtLeastIdenticalArguments(array(1))->once() //passes 357 | * ->withAtLeastIdenticalArguments(array(1, 2))->once() //passes 358 | * ->withAtLeastIdenticalArguments(array('1'))->once() //fails 359 | * ; 360 | * 361 | * If you do not want to check the type, use withIdenticalArguments. 362 | * 363 | * @param mixed[] $arguments 364 | * 365 | * @return $this 366 | */ 367 | public function withAtLeastIdenticalArguments(array $arguments) {} 368 | 369 | /** 370 | * "withAnyArguments" allow to check any argument, non-specified, when we 371 | * call the tested method (see call) of tested mock. 372 | * 373 | * This method is useful to reset the arguments of tested method, like in 374 | * the following example: 375 | * 376 | * object(new MySecondClass($mock)) 381 | * 382 | * ->mock($mock) 383 | * ->call('myMethod') 384 | * ->withArguments('first') ->once() 385 | * ->withArguments('second') ->once() 386 | * ->withAnyArguments()->exactly(2) 387 | * ; 388 | * 389 | * @return $this 390 | */ 391 | public function withAnyArguments() {} 392 | 393 | /** 394 | * "withoutAnyArgument" lets you indicate that the method should not 395 | * receive any argument when called (see call). 396 | * 397 | * when($mock = new \mock\example) 400 | * ->if($mock->test()) 401 | * ->mock($mock) 402 | * ->call('test') 403 | * ->withoutAnyArgument()->once() // passes 404 | * ->if($mock->test2('argument')) 405 | * ->mock($mock) 406 | * ->call('test2') 407 | * ->withoutAnyArgument()->once() // fails 408 | * ; 409 | * 410 | * Note: "withoutAnyArgument" is equivalent to call 411 | * withAtLeastArguments with an empty array: 412 | * "->withAtLeastArguments(array())". 413 | * 414 | * @return $this 415 | */ 416 | public function withoutAnyArgument() {} 417 | } 418 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/asserter.php: -------------------------------------------------------------------------------- 1 | boolean($true) 26 | * ->isFalse() // fails 27 | * 28 | * ->boolean($false) 29 | * ->isFalse() // succeed 30 | * ; 31 | * 32 | * @var static 33 | * 34 | * @link http://docs.atoum.org/en/latest/asserters.html#isfalse 35 | */ 36 | public $isFalse; 37 | 38 | /** 39 | * "isTrue" checks that the boolean is strictly equal to "true". 40 | * 41 | * boolean($true) 47 | * ->isTrue() // succeed 48 | * 49 | * ->boolean($false) 50 | * ->isTrue() // fails 51 | * ; 52 | * 53 | * @var static 54 | * 55 | * @link http://docs.atoum.org/en/latest/asserters.html#istrue 56 | */ 57 | public $isTrue; 58 | 59 | /** 60 | * "isTrue" checks that the boolean is strictly equal to "true". 61 | * 62 | * boolean($true) 68 | * ->isTrue() // succeed 69 | * 70 | * ->boolean($false) 71 | * ->isTrue() // fails 72 | * ; 73 | * 74 | * @param string $failMessage 75 | * 76 | * @link http://docs.atoum.org/en/latest/asserters.html#istrue 77 | * 78 | * @return $this 79 | */ 80 | public function isTrue($failMessage = null) {} 81 | 82 | /** 83 | * "isFalse" check that the boolean is strictly equal to "false". 84 | * 85 | * boolean($true) 91 | * ->isFalse() // fails 92 | * 93 | * ->boolean($false) 94 | * ->isFalse() // succeed 95 | * ; 96 | * 97 | * @param string $failMessage 98 | * 99 | * @link http://docs.atoum.org/en/latest/asserters.html#isfalse 100 | * 101 | * @return $this 102 | */ 103 | public function isFalse($failMessage = null) {} 104 | } 105 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/castToArray.php: -------------------------------------------------------------------------------- 1 | version; 15 | * } 16 | * } 17 | * 18 | * $this 19 | * ->castToString(new AtoumVersion()) 20 | * ->isEqualTo('atoum v1.0') 21 | * ; 22 | * 23 | */ 24 | class castToString extends phpString {} 25 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/constant.php: -------------------------------------------------------------------------------- 1 | dateInterval($di1) 23 | * ->isZero() // passes 24 | * ->dateInterval($di2) 25 | * ->isZero() // fails 26 | * ; 27 | * 28 | * @return $this 29 | */ 30 | public $isZero; 31 | 32 | /** 33 | * "isGreaterThan" checks that the duration of the object "DateInterval" 34 | * is higher to the duration of the given "DateInterval" object. 35 | * 36 | * dateInterval($di) 41 | * ->isGreaterThan( // passes 42 | * new DateInterval('P1D') 43 | * ) 44 | * ->isGreaterThan( // fails 45 | * new DateInterval('P2D') 46 | * ) 47 | * ; 48 | * 49 | * @param \dateInterval $interval 50 | * @param string $failMessage 51 | * 52 | * @link http://docs.atoum.org/en/latest/asserters.html#isgreaterthan 53 | * 54 | * @return $this 55 | */ 56 | public function isGreaterThan(\dateInterval $interval, $failMessage = null) {} 57 | 58 | /** 59 | * "isGreaterThanOrEqualTo" checks that the duration of the object 60 | * "DateInterval" is higher or equals to the duration of another object 61 | * "DateInterval". 62 | * 63 | * dateInterval($di) 68 | * ->isGreaterThanOrEqualTo( // passes 69 | * new DateInterval('P1D') 70 | * ) 71 | * ->isGreaterThanOrEqualTo( // passes 72 | * new DateInterval('P2D') 73 | * ) 74 | * ->isGreaterThanOrEqualTo( // fails 75 | * new DateInterval('P3D') 76 | * ) 77 | * ; 78 | * 79 | * @param \dateInterval $interval 80 | * @param string $failMessage 81 | * 82 | * @link http://docs.atoum.org/en/latest/asserters.html#isgreaterthanorequalto 83 | * 84 | * @return $this 85 | */ 86 | public function isGreaterThanOrEqualTo(\dateInterval $interval, $failMessage = null) {} 87 | 88 | /** 89 | * "isLessThan" checks that the duration of the object "DateInterval" is 90 | * lower than the duration of the given "DateInterval" object. 91 | * 92 | * dateInterval($di) 97 | * ->isLessThan( // passes 98 | * new DateInterval('P2D') 99 | * ) 100 | * ->isLessThan( // fails 101 | * new DateInterval('P1D') 102 | * ) 103 | * ; 104 | * 105 | * @param \dateInterval $interval 106 | * @param string $failMessage 107 | * 108 | * @llink http://docs.atoum.org/en/latest/asserters.html#islessthan 109 | * 110 | * @return $this 111 | */ 112 | public function isLessThan(\dateInterval $interval, $failMessage = null) {} 113 | 114 | /** 115 | * "isLessThanOrEqualTo" checks that the duration of the object 116 | * "DateInterval" is lower or equals to the duration of another object 117 | * "DateInterval". 118 | * 119 | * dateInterval($di) 124 | * ->isLessThanOrEqualTo( // passes 125 | * new DateInterval('P3D') 126 | * ) 127 | * ->isLessThanOrEqualTo( // passes 128 | * new DateInterval('P2D') 129 | * ) 130 | * ->isLessThanOrEqualTo( // fails 131 | * new DateInterval('P1D') 132 | * ) 133 | * ; 134 | * 135 | * @param \dateInterval $interval 136 | * @param string $failMessage 137 | * 138 | * @link http://docs.atoum.org/en/latest/asserters.html#islessthanorequalto 139 | * 140 | * @return $this 141 | */ 142 | public function isLessThanOrEqualTo(\dateInterval $interval, $failMessage = null) {} 143 | 144 | /** 145 | * "isEqualTo" checks that the duration of object "DateInterval" is 146 | * equals to to the duration of another "DateInterval" object. 147 | * 148 | * dateInterval($di) 153 | * ->isEqualTo( // passes 154 | * new DateInterval('P1D') 155 | * ) 156 | * ->isEqualTo( // fails 157 | * new DateInterval('P2D') 158 | * ) 159 | * ; 160 | * 161 | */ 162 | public function isEqualTo($value, $failMessage = null) {} 163 | 164 | /** 165 | * @return $this 166 | */ 167 | public function isZero($failMessage = null) {} 168 | } 169 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/dateTime.php: -------------------------------------------------------------------------------- 1 | dateTime($dt) 27 | * ->hasTimezone('Europe/Paris') 28 | * ; 29 | * 30 | * @param \dateTimezone $timezone 31 | * @param string $failMessage 32 | * 33 | * @link http://docs.atoum.org/en/latest/asserters.html#hastimezone 34 | * 35 | * @return $this 36 | */ 37 | public function hasTimezone(\dateTimezone $timezone, $failMessage = null) {} 38 | 39 | /** 40 | * "hasYear" checks year part of the "DateTime" object. 41 | * 42 | * dateTime($dt) 47 | * ->hasYear(1981) // passes 48 | * ; 49 | * 50 | * @param integer $year 51 | * @param string $failMessage 52 | * 53 | * @link http://docs.atoum.org/en/latest/asserters.html#hasyear 54 | * 55 | * @return $this 56 | */ 57 | public function hasYear($year, $failMessage = null) {} 58 | 59 | /** 60 | * "hasMonth" checks month part of the "DateTime" object. 61 | * 62 | * dateTime($dt) 67 | * ->hasMonth(2) // passes 68 | * ; 69 | * 70 | * @param integer $month 71 | * @param string $failMessage 72 | * 73 | * @link http://docs.atoum.org/en/latest/asserters.html#hasmonth 74 | * 75 | * @return $this 76 | */ 77 | public function hasMonth($month, $failMessage = null) {} 78 | 79 | /** 80 | * "hasDay" checks day part of the "DateTime" object. 81 | * 82 | * dateTime($dt) 87 | * ->hasDay(13) // passes 88 | * ; 89 | * 90 | * @param integer $day 91 | * @param string $failMessage 92 | * 93 | * @link http://docs.atoum.org/en/latest/asserters.html#hasday 94 | * 95 | * @return $this 96 | */ 97 | public function hasDay($day, $failMessage = null) {} 98 | 99 | /** 100 | * "hasDate" checks the date part of the "DateTime" object. 101 | * 102 | * dateTime($dt) 107 | * ->hasDate('1981', '02', '13') // passes 108 | * ->hasDate('1981', '2', '13') // passes 109 | * ->hasDate(1981, 2, 13) // passes 110 | * ; 111 | * 112 | * @param integer $year 113 | * @param integer $month 114 | * @param integer $day 115 | * @param string $failMessage 116 | * 117 | * @link http://docs.atoum.org/en/latest/asserters.html#hasdate 118 | * 119 | * @return $this 120 | */ 121 | public function hasDate($year, $month, $day, $failMessage = null) {} 122 | 123 | /** 124 | * "hasHours" checks time part of the "DateTime" object. 125 | * 126 | * dateTime($dt) 131 | * ->hasHours('01') // passes 132 | * ->hasHours('1') // passes 133 | * ->hasHours(1) // passes 134 | * ; 135 | * 136 | * @param integer $hours 137 | * @param string $failMessage 138 | * 139 | * @link http://docs.atoum.org/en/latest/asserters.html#hashours 140 | * 141 | * @return $this 142 | */ 143 | public function hasHours($hours, $failMessage = null) {} 144 | 145 | /** 146 | * "hasMinutes" checks minutes part of the "DateTime" object. 147 | * 148 | * dateTime($dt) 153 | * ->hasMinutes('02') // passes 154 | * ->hasMinutes('2') // passes 155 | * ->hasMinutes(2) // passes 156 | * ; 157 | * 158 | * @param integer $minutes 159 | * @param string $failMessage 160 | * 161 | * @link http://docs.atoum.org/en/latest/asserters.html#hasminutes 162 | * 163 | * @return $this 164 | */ 165 | public function hasMinutes($minutes, $failMessage = null) {} 166 | 167 | /** 168 | * "hasSeconds" checks seconds part of the "DateTime" object. 169 | * 170 | * dateTime($dt) 175 | * ->hasSeconds('03') // passes 176 | * ->hasSeconds('3') // passes 177 | * ->hasSeconds(3) // passes 178 | * ; 179 | * 180 | * @param integer $seconds 181 | * @param string $failMessage 182 | * 183 | * @link http://docs.atoum.org/en/latest/asserters.html#hasseconds 184 | * 185 | * @return $this 186 | */ 187 | public function hasSeconds($seconds, $failMessage = null) {} 188 | 189 | /** 190 | * "hasTime" checks time part of the "DateTime" object. 191 | * 192 | * dateTime($dt) 197 | * ->hasTime('01', '02', '03') // passes 198 | * ->hasTime('1', '2', '3') // passes 199 | * ->hasTime(1, 2, 3) // passes 200 | * ; 201 | * 202 | * @param integer $hours 203 | * @param integer $minutes 204 | * @param integer $seconds 205 | * @param string $failMessage 206 | * 207 | * @link http://docs.atoum.org/en/latest/asserters.html#hastime 208 | * 209 | * @return $this 210 | */ 211 | public function hasTime($hours, $minutes, $seconds, $failMessage = null) {} 212 | 213 | /** 214 | * "hasDateAndTime" checks date and hour part of the "DateTime" object. 215 | * 216 | * dateTime($dt) 221 | * // passes 222 | * ->hasDateAndTime('1981', '02', '13', '01', '02', '03') 223 | * // passes 224 | * ->hasDateAndTime('1981', '2', '13', '1', '2', '3') 225 | * // passes 226 | * ->hasDateAndTime(1981, 2, 13, 1, 2, 3) 227 | * ; 228 | * 229 | * @param integer $year 230 | * @param integer $month 231 | * @param integer $day 232 | * @param integer $hours 233 | * @param integer $minutes 234 | * @param integer $seconds 235 | * @param string $failMessage 236 | * 237 | * @link http://docs.atoum.org/en/latest/asserters.html#hasdateandtime 238 | * 239 | * @return $this 240 | */ 241 | public function hasDateAndTime($year, $month, $day, $hours, $minutes, $seconds, $failMessage = null) {} 242 | 243 | /** 244 | * @param string $failMessage 245 | * 246 | * @return $this 247 | */ 248 | public function isImmutable($failMessage = null) {} 249 | } 250 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/error.php: -------------------------------------------------------------------------------- 1 | when( 11 | * function() { 12 | * trigger_error('message'); 13 | * } 14 | * ) 15 | * ->error() 16 | * ->exists() // or notExists 17 | * ; 18 | * 19 | * Note: The syntax uses anonymous functions (also called closures) 20 | * introduced in PHP 5.3. For more details, read the PHP's 21 | * documentation on anonymous functions. 22 | * 23 | * Warning: The error types E_ERROR, E_PARSE, E_CORE_ERROR, 24 | * E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING as well as the 25 | * E_STRICT can't be managed with this function. 26 | * 27 | */ 28 | class error extends asserter 29 | { 30 | /** 31 | * "exists" checks that an error was raised during the execution of the 32 | * previous code. 33 | * 34 | * when( 37 | * function() { 38 | * trigger_error('message'); 39 | * } 40 | * ) 41 | * ->error() 42 | * ->exists() // pass 43 | * 44 | * ->when( 45 | * function() { 46 | * // code without error 47 | * } 48 | * ) 49 | * ->error() 50 | * ->exists() // failed 51 | * ; 52 | * 53 | * @var static 54 | * 55 | * @link http://docs.atoum.org/en/latest/asserters.html#exists 56 | */ 57 | public $exists; 58 | 59 | /** 60 | * "notExists" checks that no errors was raised during the execution of 61 | * the previous code. 62 | * 63 | * when( 66 | * function() { 67 | * trigger_error('message'); 68 | * } 69 | * ) 70 | * ->error() 71 | * ->notExists() // fails 72 | * 73 | * ->when( 74 | * function() { 75 | * // code without error 76 | * } 77 | * ) 78 | * ->error() 79 | * ->notExists() // pass 80 | * ; 81 | * 82 | * @var static 83 | * 84 | * @link http://docs.atoum.org/en/latest/asserters.html#notexists 85 | */ 86 | public $notExists; 87 | 88 | /** 89 | * "withAnyType" does not check the type of the raised error. That's the 90 | * default behaviour. So "->error()->withAnyType()->exists()" is the 91 | * equivalent of "->error()->exists()". This method allow to add semantic 92 | * to your test. 93 | * 94 | * when( 97 | * function() { 98 | * trigger_error('message'); 99 | * } 100 | * ) 101 | * ->error() 102 | * ->withAnyType() // pass 103 | * ->exists() 104 | * ->when( 105 | * function() { 106 | * } 107 | * ) 108 | * ->error() 109 | * ->withAnyType() 110 | * ->exists() // fails 111 | * ; 112 | * 113 | * @var static 114 | */ 115 | public $withAnyType; 116 | 117 | /** 118 | * "withAnyMessage" does not check the error message. That's the default 119 | * behaviour. So "->error()->withAnyMessage()->exists()" is the 120 | * equivalent of "->error()->exists()". This method allow to add semantic 121 | * to your test. 122 | * 123 | * when( 126 | * function() { 127 | * trigger_error(); 128 | * } 129 | * ) 130 | * ->error() 131 | * ->withAnyMessage() 132 | * ->exists() // passes 133 | * ; 134 | * 135 | * $this 136 | * ->when( 137 | * function() { 138 | * trigger_error('message'); 139 | * } 140 | * ) 141 | * ->error() 142 | * ->withAnyMessage() 143 | * ->exists() // passes 144 | * ; 145 | * 146 | * $this 147 | * ->when( 148 | * function() { 149 | * } 150 | * ) 151 | * ->error() 152 | * ->withAnyMessage() 153 | * ->exists() // fails 154 | * ; 155 | * 156 | * @var static 157 | */ 158 | public $withAnyMessage; 159 | 160 | /** 161 | * "exists" checks that an error was raised during the execution of the 162 | * previous code. 163 | * 164 | * when( 167 | * function() { 168 | * trigger_error('message'); 169 | * } 170 | * ) 171 | * ->error() 172 | * ->exists() // pass 173 | * 174 | * ->when( 175 | * function() { 176 | * // code without error 177 | * } 178 | * ) 179 | * ->error() 180 | * ->exists() // failed 181 | * ; 182 | * 183 | * @link http://docs.atoum.org/en/latest/asserters.html#exists 184 | * 185 | * @return $this 186 | */ 187 | public function exists() {} 188 | 189 | /** 190 | * "notExists" checks that no errors was raised during the execution of 191 | * the previous code. 192 | * 193 | * when( 196 | * function() { 197 | * trigger_error('message'); 198 | * } 199 | * ) 200 | * ->error() 201 | * ->notExists() // fails 202 | * 203 | * ->when( 204 | * function() { 205 | * // code without error 206 | * } 207 | * ) 208 | * ->error() 209 | * ->notExists() // pass 210 | * ; 211 | * 212 | * @link http://docs.atoum.org/en/latest/asserters.html#notexists 213 | * 214 | * @return $this 215 | */ 216 | public function notExists() {} 217 | 218 | /** 219 | * "withType" checks the type of the raised error. 220 | * 221 | * when( 224 | * function() { 225 | * trigger_error('message'); 226 | * } 227 | * ) 228 | * ->error() 229 | * ->withType(E_USER_NOTICE) // pass 230 | * ->exists() 231 | * 232 | * ->when( 233 | * function() { 234 | * trigger_error('message'); 235 | * } 236 | * ) 237 | * ->error() 238 | * ->withType(E_USER_WARNING) // failed 239 | * ->exists() 240 | * ; 241 | * 242 | * @param integer $type 243 | * 244 | * @link http://docs.atoum.org/en/latest/asserters.html#withtype 245 | * 246 | * @return $this 247 | */ 248 | public function withType($type) {} 249 | 250 | /** 251 | * "withAnyType" does not check the type of the raised error. That's the 252 | * default behaviour. So "->error()->withAnyType()->exists()" is the 253 | * equivalent of "->error()->exists()". This method allow to add semantic 254 | * to your test. 255 | * 256 | * when( 259 | * function() { 260 | * trigger_error('message'); 261 | * } 262 | * ) 263 | * ->error() 264 | * ->withAnyType() // pass 265 | * ->exists() 266 | * ->when( 267 | * function() { 268 | * } 269 | * ) 270 | * ->error() 271 | * ->withAnyType() 272 | * ->exists() // fails 273 | * ; 274 | * 275 | * @return $this 276 | */ 277 | public function withAnyType() {} 278 | 279 | /** 280 | * "withMessage" checks message content of raised error. 281 | * 282 | * when( 285 | * function() { 286 | * trigger_error('message'); 287 | * } 288 | * ) 289 | * ->error() 290 | * ->withMessage('message') 291 | * ->exists() // passes 292 | * ; 293 | * 294 | * $this 295 | * ->when( 296 | * function() { 297 | * trigger_error('message'); 298 | * } 299 | * ) 300 | * ->error() 301 | * ->withMessage('MESSAGE') 302 | * ->exists() // fails 303 | * ; 304 | * 305 | * @param string $message 306 | * 307 | * @return $this 308 | */ 309 | public function withMessage($message) {} 310 | 311 | /** 312 | * "withPattern" checks message content of raised error against a regular 313 | * expression. 314 | * 315 | * when( 318 | * function() { 319 | * trigger_error('message'); 320 | * } 321 | * ) 322 | * ->error() 323 | * ->withPattern('/^mess.*$/') 324 | * ->exists() // passes 325 | * ; 326 | * 327 | * $this 328 | * ->when( 329 | * function() { 330 | * trigger_error('message'); 331 | * } 332 | * ) 333 | * ->error() 334 | * ->withPattern('/^mess$/') 335 | * ->exists() // fails 336 | * ; 337 | * 338 | * @param string $pattern 339 | * 340 | * @return $this 341 | */ 342 | public function withPattern($pattern) {} 343 | 344 | /** 345 | * "withAnyMessage" does not check the error message. That's the default 346 | * behaviour. So "->error()->withAnyMessage()->exists()" is the 347 | * equivalent of "->error()->exists()". This method allow to add semantic 348 | * to your test. 349 | * 350 | * when( 353 | * function() { 354 | * trigger_error(); 355 | * } 356 | * ) 357 | * ->error() 358 | * ->withAnyMessage() 359 | * ->exists() // passes 360 | * ; 361 | * 362 | * $this 363 | * ->when( 364 | * function() { 365 | * trigger_error('message'); 366 | * } 367 | * ) 368 | * ->error() 369 | * ->withAnyMessage() 370 | * ->exists() // passes 371 | * ; 372 | * 373 | * $this 374 | * ->when( 375 | * function() { 376 | * } 377 | * ) 378 | * ->error() 379 | * ->withAnyMessage() 380 | * ->exists() // fails 381 | * ; 382 | * 383 | * @return $this 384 | */ 385 | public function withAnyMessage() {} 386 | } 387 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/exception.php: -------------------------------------------------------------------------------- 1 | exception( 11 | * function() use($myObject) { 12 | * // this code throws an exception: throw new \Exception; 13 | * $myObject->doOneThing('wrongParameter'); 14 | * } 15 | * ) 16 | * ; 17 | * 18 | * Note: The syntax uses anonymous functions (also called closures) 19 | * introduced in PHP 5.3. For more details, read the PHP's 20 | * documentation on anonymous functions. 21 | * 22 | * We can easily retrieve the last exception with "$this->exception". 23 | * 24 | * exception( 27 | * function() use($myObject) { 28 | * // This code throws a exception: throw new \Exception('Message', 42); 29 | * $myObject->doOneThing('wrongParameter'); 30 | * } 31 | * )->isIdenticalTo($this->exception) // passes 32 | * ; 33 | * 34 | * $this->exception->hasCode(42); // passes 35 | * $this->exception->hasMessage('erreur'); // passes 36 | * 37 | */ 38 | class exception extends phpObject 39 | { 40 | /** 41 | * "hasDefaultCode" checks that exception code is the default value, 0. 42 | * 43 | * exception( 46 | * function() use($myObject) { 47 | * // this code throws an exception: throw new \Exception; 48 | * $myObject->doOneThing('wrongParameter'); 49 | * } 50 | * ) 51 | * ->hasDefaultCode() 52 | * ; 53 | * 54 | * Note: "hasDefaultCode" is equivalent to "hasCode(0)". 55 | * 56 | * @var static 57 | * 58 | * @link http://docs.atoum.org/en/latest/asserters.html#hasdefaultcode 59 | */ 60 | public $hasDefaultCode; 61 | 62 | /** 63 | * "message" allow you to get an asserter of type string containing the 64 | * tested exception message. 65 | * 66 | * exception( 69 | * function() { 70 | * throw new \Exception('My custom message to test'); 71 | * } 72 | * ) 73 | * ->message 74 | * ->contains('message') 75 | * ; 76 | * 77 | * @var phpString 78 | */ 79 | public $message; 80 | 81 | /** 82 | * "hasDefaultCode" checks that exception code is the default value, 0. 83 | * 84 | * exception( 87 | * function() use($myObject) { 88 | * // this code throws an exception: throw new \Exception; 89 | * $myObject->doOneThing('wrongParameter'); 90 | * } 91 | * ) 92 | * ->hasDefaultCode() 93 | * ; 94 | * 95 | * Note: "hasDefaultCode" is equivalent to "hasCode(0)". 96 | * 97 | * @param string $failMessage 98 | * 99 | * @link http://docs.atoum.org/en/latest/asserters.html#hasdefaultcode 100 | * 101 | * @return $this 102 | */ 103 | public function hasDefaultCode($failMessage = null) {} 104 | 105 | /** 106 | * "hasCode" checks exception code. 107 | * 108 | * exception( 111 | * function() use($myObject) { 112 | * // This code throws a exception: throw new \Exception('Message', 42); 113 | * $myObject->doOneThing('wrongParameter'); 114 | * } 115 | * ) 116 | * ->hasCode(42) 117 | * ; 118 | * 119 | * @param integer $code 120 | * @param string $failMessage 121 | * 122 | * @link http://docs.atoum.org/en/latest/asserters.html#hascode 123 | * 124 | * @return $this 125 | */ 126 | public function hasCode($code, $failMessage = null) {} 127 | 128 | /** 129 | * "hasMessage" checks exception message. 130 | * 131 | * exception( 134 | * function() use($myObject) { 135 | * // This code throws a exception: throw new \Exception('Message'); 136 | * $myObject->doOneThing('wrongParameter'); 137 | * } 138 | * ) 139 | * ->hasMessage('Message') // passes 140 | * ->hasMessage('message') // fails 141 | * ; 142 | * 143 | * @param string $message 144 | * @param string $failMessage 145 | * 146 | * @link http://docs.atoum.org/en/latest/asserters.html#hasmessage 147 | * 148 | * @return $this 149 | */ 150 | public function hasMessage($message, $failMessage = null) {} 151 | 152 | /** 153 | * "hasNestedException" checks that the exception contains a reference to 154 | * another exception. If the exception type is given, this will also 155 | * checks the exception class. 156 | * 157 | * exception( 160 | * function() use($myObject) { 161 | * // This code throws a exception: throw new \Exception('Message'); 162 | * $myObject->doOneThing('wrongParameter'); 163 | * } 164 | * ) 165 | * ->hasNestedException() // fails 166 | * 167 | * ->exception( 168 | * function() use($myObject) { 169 | * try { 170 | * // This code throws a exception: throw new \FirstException('Message 1', 42); 171 | * $myObject->doOneThing('wrongParameter'); 172 | * } 173 | * // ... the exception is caught... 174 | * catch(\FirstException $e) { 175 | * // ... and then throws encapsulated inside a second one 176 | * throw new \SecondException('Message 2', 24, $e); 177 | * } 178 | * } 179 | * ) 180 | * ->isInstanceOf('\FirstException') // fails 181 | * ->isInstanceOf('\SecondException') // passes 182 | * 183 | * ->hasNestedException() // passes 184 | * ->hasNestedException(new \FirstException) // passes 185 | * ->hasNestedException(new \SecondException) // fails 186 | * ; 187 | * 188 | * @param \exception $exception 189 | * @param string $failMessage 190 | * 191 | * @link http://docs.atoum.org/en/latest/asserters.html#hasnestedexception 192 | * 193 | * @return $this 194 | */ 195 | public function hasNestedException(?\exception $exception = null, $failMessage = null) {} 196 | } 197 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/extension.php: -------------------------------------------------------------------------------- 1 | extension('json') 13 | * ->isLoaded() 14 | * ; 15 | * 16 | * Note: If you need to run tests only if an extension is present, you 17 | * can use the PHP annotation. 18 | * 19 | * @param string $failMessage 20 | * 21 | * @return $this 22 | */ 23 | public function isLoaded($failMessage = null) {} 24 | } 25 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/generator.php: -------------------------------------------------------------------------------- 1 | yields" the next value of the generator 12 | * will be retrived. You will be able to use any other asserter on this 13 | * value (for example "class", "string" or "variable"). 14 | * 15 | * Example: 16 | * 17 | * generator($generator()) 25 | * ->yields->variable->isEqualTo(1) 26 | * ->yields->variable->isEqualTo(2) 27 | * ->yields->integer->isEqualTo(3) 28 | * ; 29 | * 30 | * In this example we create a generator that yields 3 values : 1, 2 and 31 | * 3. Then we yield each value and run an assertion on this value to 32 | * check it's type and value. In the first two yields we use the 33 | * "variable" asserter and only check the value. In the third yields call 34 | * we add a check on the type of the value by using the integer asserter 35 | * (any asserter could by used on this value) before checking the value. 36 | * 37 | * @var asserter 38 | */ 39 | public $yields; 40 | 41 | /** 42 | * Note: This assertion will only work on PHP >= 7.0. 43 | * 44 | * Since the version 7.0 of PHP, generators can return a value that can 45 | * retrived via a call to the "->getReturn()" method. When you call 46 | * "->returns" on the generator asserter, atoum will retrive the value 47 | * from a call on the "->getReturn()" method on the asserter. Then you 48 | * will be able to use any other asserter on this value just like the 49 | * "yields" assertion. 50 | * 51 | * Example: 52 | * 53 | * generator($generator()) 62 | * ->yields->variable->isEqualTo(1) 63 | * ->yields->variable->isEqualTo(2) 64 | * ->yields->integer->isEqualTo(3) 65 | * ->returns->integer->isEqualTo(42) 66 | * ; 67 | * 68 | * In this example we run some checks on all the yielded values. Then, we 69 | * checks that the generator returns a integer with a value of 42 (just 70 | * like a call to the yields assertion, you can use any asserter to check 71 | * to returned value). 72 | * 73 | * @return asserter 74 | */ 75 | public $returns; 76 | 77 | /** 78 | * @return asserter 79 | */ 80 | public function getReturn() {} 81 | } 82 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/hash.php: -------------------------------------------------------------------------------- 1 | hash($hash) 22 | * ->isSha1() // passes 23 | * ->hash($notHash) 24 | * ->isSha1() // fails 25 | * ; 26 | * 27 | * @var static 28 | * 29 | * @link http://docs.atoum.org/en/latest/asserters.html#issha1 30 | */ 31 | public $isSha1; 32 | 33 | /** 34 | * "isSha256" checks that the string is a "sha256" format, i.e. a 35 | * hexadecimal string of 64 length. 36 | * 37 | * hash($hash) 43 | * ->isSha256() // passes 44 | * ->hash($notHash) 45 | * ->isSha256() // fails 46 | * ; 47 | * 48 | * @var static 49 | * 50 | * @link http://docs.atoum.org/en/latest/asserters.html#issha256 51 | */ 52 | public $isSha256; 53 | 54 | /** 55 | * "isSha512" checks that the string is a "sha512" format, i.e. a 56 | * hexadecimal string of 128 length. 57 | * 58 | * hash($hash) 64 | * ->isSha512() // passes 65 | * ->hash($notHash) 66 | * ->isSha512() // fails 67 | * ; 68 | * 69 | * @var static 70 | * 71 | * @link http://docs.atoum.org/en/latest/asserters.html#issha512 72 | */ 73 | public $isSha512; 74 | 75 | /** 76 | * "isMd5" checks that the string is a "md5" format, i.r. a hexadecimal 77 | * string of 32 length. 78 | * 79 | * hash($hash) 85 | * ->isMd5() // passes 86 | * ->hash($notHash) 87 | * ->isMd5() // fails 88 | * ; 89 | * 90 | * @var static 91 | * 92 | * @link http://docs.atoum.org/en/latest/asserters.html#ismd5 93 | */ 94 | public $isMd5; 95 | 96 | /** 97 | * "isSha1" checks that the string is a "sha1" format, i.e. a hexadecimal 98 | * string of 40 length. 99 | * 100 | * hash($hash) 106 | * ->isSha1() // passes 107 | * ->hash($notHash) 108 | * ->isSha1() // fails 109 | * ; 110 | * 111 | * @param string $failMessage 112 | * 113 | * @link http://docs.atoum.org/en/latest/asserters.html#issha1 114 | * 115 | * @return $this 116 | */ 117 | public function isSha1($failMessage = null) {} 118 | 119 | /** 120 | * "isSha256" checks that the string is a "sha256" format, i.e. a 121 | * hexadecimal string of 64 length. 122 | * 123 | * hash($hash) 129 | * ->isSha256() // passes 130 | * ->hash($notHash) 131 | * ->isSha256() // fails 132 | * ; 133 | * 134 | * @param string $failMessage 135 | * 136 | * @link http://docs.atoum.org/en/latest/asserters.html#issha256 137 | * 138 | * @return $this 139 | */ 140 | public function isSha256($failMessage = null) {} 141 | 142 | /** 143 | * "isSha512" checks that the string is a "sha512" format, i.e. a 144 | * hexadecimal string of 128 length. 145 | * 146 | * hash($hash) 152 | * ->isSha512() // passes 153 | * ->hash($notHash) 154 | * ->isSha512() // fails 155 | * ; 156 | * 157 | * @param string $failMessage 158 | * 159 | * @link http://docs.atoum.org/en/latest/asserters.html#issha512 160 | * 161 | * @return $this 162 | */ 163 | public function isSha512($failMessage = null) {} 164 | 165 | /** 166 | * "isMd5" checks that the string is a "md5" format, i.r. a hexadecimal 167 | * string of 32 length. 168 | * 169 | * hash($hash) 175 | * ->isMd5() // passes 176 | * ->hash($notHash) 177 | * ->isMd5() // fails 178 | * ; 179 | * 180 | * @param string $failMessage 181 | * 182 | * @link http://docs.atoum.org/en/latest/asserters.html#ismd5 183 | * 184 | * @return $this 185 | */ 186 | public function isMd5($failMessage = null) {} 187 | } 188 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/integer.php: -------------------------------------------------------------------------------- 1 | integer($zero) 26 | * ->isZero() // passes 27 | * 28 | * ->integer($notZero) 29 | * ->isZero() // fails 30 | * ; 31 | * 32 | * Note: "isZero" is equivalent to "isEqualTo(0)". 33 | * 34 | * @var static 35 | * 36 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-zero 37 | */ 38 | public $isZero; 39 | 40 | /** 41 | * "isZero" checks that the integer is equal to 0. 42 | * 43 | * integer($zero) 49 | * ->isZero() // passes 50 | * 51 | * ->integer($notZero) 52 | * ->isZero() // fails 53 | * ; 54 | * 55 | * Note: "isZero" is equivalent to "isEqualTo(0)". 56 | * 57 | * @param string $failMessage 58 | * 59 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-zero 60 | * 61 | * @return $this 62 | */ 63 | public function isZero($failMessage = null) {} 64 | 65 | /** 66 | * "isGreaterThan" checks that the integer is strictly higher than given 67 | * one. 68 | * 69 | * integer($zero) 74 | * ->isGreaterThan(-1) // passes 75 | * ->isGreaterThan('-1') // fails because "-1" 76 | * // isn't an integer 77 | * ->isGreaterThan(0) // fails 78 | * ; 79 | * 80 | * @param integer|float $value 81 | * @param string $failMessage 82 | * 83 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-greater-than 84 | * 85 | * @return $this 86 | */ 87 | public function isGreaterThan($value, $failMessage = null) {} 88 | 89 | /** 90 | * "isGreaterThanOrEqualTo" checks that an integer is higher or equal to 91 | * a given one. 92 | * 93 | * integer($zero) 98 | * ->isGreaterThanOrEqualTo(-1) // passes 99 | * ->isGreaterThanOrEqualTo(0) // passes 100 | * ->isGreaterThanOrEqualTo('-1') // fails because "-1" 101 | * // isn't an integer 102 | * ; 103 | * 104 | * @param integer|float $value 105 | * @param string $failMessage 106 | * 107 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-greater-than-or-equal-to 108 | * 109 | * @return $this 110 | */ 111 | public function isGreaterThanOrEqualTo($value, $failMessage = null) {} 112 | 113 | /** 114 | * "isLessThan" checks that the integer is strictly lower than a given 115 | * one. 116 | * 117 | * integer($zero) 122 | * ->isLessThan(10) // passes 123 | * ->isLessThan('10') // fails because"10" isn't an integer 124 | * ->isLessThan(0) // fails 125 | * ; 126 | * 127 | * @param integer|float $value 128 | * @param string $failMessage 129 | * 130 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-less-than 131 | * 132 | * @return $this 133 | */ 134 | public function isLessThan($value, $failMessage = null) {} 135 | 136 | /** 137 | * "isLessThanOrEqualTo" checks that an integer is lower or equal to a 138 | * given one. 139 | * 140 | * integer($zero) 145 | * ->isLessThanOrEqualTo(10) // passes 146 | * ->isLessThanOrEqualTo(0) // passes 147 | * ->isLessThanOrEqualTo('10') // fails because "10" 148 | * // isn't an integer 149 | * ; 150 | * 151 | * @param integer|float $value 152 | * @param string $failMessage 153 | * 154 | * @link http://docs.atoum.org/en/latest/asserters.html#integer-is-greater-than-or-equal-to 155 | * 156 | * @return $this 157 | */ 158 | public function isLessThanOrEqualTo($value, $failMessage = null) {} 159 | } 160 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/iterator.php: -------------------------------------------------------------------------------- 1 | mock($mock) 13 | * ; 14 | * 15 | * Note: Refer to the documentation of mock for more information on how 16 | * to create and manage mocks. 17 | * 18 | * @method call receive($function) 19 | */ 20 | class mock extends adapter 21 | { 22 | /** 23 | * "wasCalled" checks that at least one method of the mock has been 24 | * called at least once. 25 | * 26 | * object(new MySecondClass($mock)) 31 | * 32 | * ->mock($mock) 33 | * ->wasCalled() 34 | * ; 35 | * 36 | * @param string $failMessage 37 | * 38 | * @link http://docs.atoum.org/en/latest/asserters.html#wascalled 39 | * 40 | * @return $this 41 | */ 42 | public function wasCalled($failMessage = null) {} 43 | 44 | /** 45 | * "wasNotCalled" checks that no method of the mock has been called. 46 | * 47 | * object(new MySecondClass($mock)) 52 | * 53 | * ->mock($mock) 54 | * ->wasNotCalled() 55 | * ; 56 | * 57 | * @param string $failMessage 58 | * 59 | * @link http://docs.atoum.org/en/latest/asserters.html#wasnotcalled 60 | * 61 | * @return $this 62 | */ 63 | public function wasNotCalled($failMessage = null) {} 64 | } 65 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/mysqlDateTime.php: -------------------------------------------------------------------------------- 1 | output( 12 | * function() { 13 | * echo 'Hello world'; 14 | * } 15 | * ) 16 | * ; 17 | * 18 | * Note: The syntax uses anonymous functions (also called closures) 19 | * introduced in PHP 5.3. For more details, read the PHP's 20 | * documentation on anonymous functions. 21 | * 22 | */ 23 | class output extends phpString {} 24 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/phpArray.php: -------------------------------------------------------------------------------- 1 | phpArray()`` 16 | * or "->array()". 17 | * 18 | * It's recommended to use only "->array()" in order to simplify the 19 | * reading of tests. 20 | * 21 | */ 22 | class phpArray extends variable implements \arrayAccess 23 | { 24 | /** 25 | * "isEmpty" checks that an array is empty. 26 | * 27 | * array($emptyArray) 33 | * ->isEmpty() // passes 34 | * 35 | * ->array($nonEmptyArray) 36 | * ->isEmpty() // fails 37 | * ; 38 | * 39 | * @var static 40 | * 41 | * @link http://docs.atoum.org/en/latest/asserters.html#isempty 42 | */ 43 | public $isEmpty; 44 | 45 | /** 46 | * "isNotEmpty" checks that an array is not empty. 47 | * 48 | * array($emptyArray) 54 | * ->isNotEmpty() // fails 55 | * 56 | * ->array($nonEmptyArray) 57 | * ->isNotEmpty() // passes 58 | * ; 59 | * 60 | * @var static 61 | * 62 | * @link http://docs.atoum.org/en/latest/asserters.html#isnotempty 63 | */ 64 | public $isNotEmpty; 65 | 66 | /** 67 | * "hasSize" checks the size of an array. 68 | * 69 | * array($fibonacci) 74 | * ->hasSize(7) // passes 75 | * ->hasSize(10) // fails 76 | * ; 77 | * 78 | * Note: "hasSize" is not recursive. 79 | * 80 | * @param integer $size 81 | * @param string $failMessage 82 | * 83 | * @link http://docs.atoum.org/en/latest/asserters.html#hassize 84 | * 85 | * @return $this 86 | */ 87 | public function hasSize($size, $failMessage = null) {} 88 | 89 | /** 90 | * "isEmpty" checks that an array is empty. 91 | * 92 | * array($emptyArray) 98 | * ->isEmpty() // passes 99 | * 100 | * ->array($nonEmptyArray) 101 | * ->isEmpty() // fails 102 | * ; 103 | * 104 | * @param string $failMessage 105 | * 106 | * @link http://docs.atoum.org/en/latest/asserters.html#isempty 107 | * 108 | * @return $this 109 | */ 110 | public function isEmpty($failMessage = null) {} 111 | 112 | /** 113 | * "isNotEmpty" checks that an array is not empty. 114 | * 115 | * array($emptyArray) 121 | * ->isNotEmpty() // fails 122 | * 123 | * ->array($nonEmptyArray) 124 | * ->isNotEmpty() // passes 125 | * ; 126 | * 127 | * @param string $failMessage 128 | * 129 | * @link http://docs.atoum.org/en/latest/asserters.html#isnotempty 130 | * 131 | * @return $this 132 | */ 133 | public function isNotEmpty($failMessage = null) {} 134 | 135 | /** 136 | * "strictlyContains" checks that an array contains some data (same value 137 | * and same type). 138 | * 139 | * array($fibonacci) 144 | * ->strictlyContains('1') // passes 145 | * ->strictlyContains(1) // fails 146 | * ->strictlyContains('2') // fails 147 | * ->strictlyContains(2) // passes 148 | * ->strictlyContains(10) // fails 149 | * ; 150 | * 151 | * Note: "strictlyContains" doesn't search recursively. 152 | * 153 | * check the type, use contains. 154 | * 155 | * @param mixed $value 156 | * @param string $failMessage 157 | * 158 | * @link http://docs.atoum.org/en/latest/asserters.html#strictlycontains 159 | * 160 | * @return $this 161 | */ 162 | public function strictlyContains($value, $failMessage = null) {} 163 | 164 | /** 165 | * "contains" check that array contains some data. 166 | * 167 | * array($fibonacci) 172 | * ->contains('1') // succeed 173 | * ->contains(1) // succeed, but data type... 174 | * ->contains('2') // ... is not checked 175 | * ->contains(10) // failed 176 | * ; 177 | * 178 | * Note: "contains" doesn't check recursively. 179 | * 180 | * check its type, use strictlyContains. 181 | * 182 | * @param mixed $value 183 | * @param string $failMessage 184 | * 185 | * @link http://docs.atoum.org/en/latest/asserters.html#contains 186 | * 187 | * @return $this 188 | */ 189 | public function contains($value, $failMessage = null) {} 190 | 191 | /** 192 | * "strictlyNotContains" check that an array doesn't contains a data 193 | * (same value and same type). 194 | * 195 | * array($fibonacci) 200 | * ->strictlyNotContains(null) // passes 201 | * ->strictlyNotContains('1') // fails 202 | * ->strictlyNotContains(1) // passes 203 | * ->strictlyNotContains(10) // passes 204 | * ; 205 | * 206 | * Note: "strictlyNotContains" doesn't search recursively. 207 | * 208 | * check the type, use contains. 209 | * 210 | * @param mixed $value 211 | * @param string $failMessage 212 | * 213 | * @link http://docs.atoum.org/en/latest/asserters.html#strictlynotcontains 214 | * 215 | * @return $this 216 | */ 217 | public function strictlyNotContains($value, $failMessage = null) {} 218 | 219 | /** 220 | * "notContains" checks that an array doesn't contains a given data. 221 | * 222 | * array($fibonacci) 227 | * ->notContains(null) // passes 228 | * ->notContains(1) // fails 229 | * ->notContains(10) // passes 230 | * ; 231 | * 232 | * Note: "notContains" doesn't search recursively. 233 | * 234 | * to check its type, use strictlyNotContains. 235 | * 236 | * @param mixed $value 237 | * @param string $failMessage 238 | * 239 | * @link http://docs.atoum.org/en/latest/asserters.html#notcontains 240 | * 241 | * @return $this 242 | */ 243 | public function notContains($value, $failMessage = null) {} 244 | 245 | /** 246 | * "hasKeys" checks that an array contains all given keys. 247 | * 248 | * 'atoum', 252 | * 'owner' => 'mageekguy', 253 | * ); 254 | * 255 | * $this 256 | * ->array($fibonacci) 257 | * ->hasKeys(array(0, 2, 4)) // passes 258 | * ->hasKeys(array('0', 2)) // passes 259 | * ->hasKeys(array('4', 0, 3)) // passes 260 | * ->hasKeys(array(0, 3, 10)) // fails 261 | * 262 | * ->array($atoum) 263 | * ->hasKeys(array('name', 'owner')) // passes 264 | * ->hasKeys(array('name', 'price')) // fails 265 | * ; 266 | * 267 | * Note: "hasKeys" doesn't search recursively. 268 | * 269 | * Warning: "hasKeys" doesn't test the keys type. 270 | * 271 | * @param mixed[] $keys 272 | * @param string $failMessage 273 | * 274 | * @link http://docs.atoum.org/en/latest/asserters.html#haskeys 275 | * 276 | * @return $this 277 | */ 278 | public function hasKeys(array $keys, $failMessage = null) {} 279 | 280 | /** 281 | * "notHasKeys" checks that an array doesn't contains any keys from a 282 | * given array. 283 | * 284 | * 'atoum', 288 | * 'owner' => 'mageekguy', 289 | * ); 290 | * 291 | * $this 292 | * ->array($fibonacci) 293 | * ->notHasKeys(array(0, 2, 4)) // fails 294 | * ->notHasKeys(array('0', 2)) // fails 295 | * ->notHasKeys(array('4', 0, 3)) // fails 296 | * ->notHasKeys(array(10, 11, 12)) // passes 297 | * 298 | * ->array($atoum) 299 | * ->notHasKeys(array('name', 'owner')) // fails 300 | * ->notHasKeys(array('foo', 'price')) // passes 301 | * ; 302 | * 303 | * Note: "notHasKeys" doesn't search recursively. 304 | * 305 | * Warning: "notHasKeys" doesn't test keys type. 306 | * 307 | * @param mixed[] $keys 308 | * @param string $failMessage 309 | * 310 | * @link http://docs.atoum.org/en/latest/asserters.html#nothaskeys 311 | * 312 | * @return $this 313 | */ 314 | public function notHasKeys(array $keys, $failMessage = null) {} 315 | 316 | /** 317 | * "hasKey" check that the table contains a given key. 318 | * 319 | * 'atoum', 323 | * 'owner' => 'mageekguy', 324 | * ); 325 | * 326 | * $this 327 | * ->array($fibonacci) 328 | * ->hasKey(0) // passes 329 | * ->hasKey(1) // passes 330 | * ->hasKey('1') // passes 331 | * ->hasKey(10) // failed 332 | * 333 | * ->array($atoum) 334 | * ->hasKey('name') // passes 335 | * ->hasKey('price') // fails 336 | * ; 337 | * 338 | * Note: "hasKey" doesn't search recursively. 339 | * 340 | * Warning: "hasKey" doesn't test the key type. 341 | * 342 | * @param mixed $key 343 | * @param string $failMessage 344 | * 345 | * @link http://docs.atoum.org/en/latest/asserters.html#haskey 346 | * 347 | * @return $this 348 | */ 349 | public function hasKey($key, $failMessage = null) {} 350 | 351 | /** 352 | * "notHasKey" checks that an array doesn't contains a given key. 353 | * 354 | * 'atoum', 358 | * 'owner' => 'mageekguy', 359 | * ); 360 | * 361 | * $this 362 | * ->array($fibonacci) 363 | * ->notHasKey(0) // fails 364 | * ->notHasKey(1) // fails 365 | * ->notHasKey('1') // fails 366 | * ->notHasKey(10) // passes 367 | * 368 | * ->array($atoum) 369 | * ->notHasKey('name') // fails 370 | * ->notHasKey('price') // passes 371 | * ; 372 | * 373 | * Note: "notHasKey" doesn't search recursively. 374 | * 375 | * Warning: "notHasKey" doesn't test keys type. 376 | * 377 | * @param mixed $key 378 | * @param string $failMessage 379 | * 380 | * @link http://docs.atoum.org/en/latest/asserters.html#nothaskeys 381 | * 382 | * @return $this 383 | */ 384 | public function notHasKey($key, $failMessage = null) {} 385 | 386 | /** 387 | * "containsValues" checks that an array contains all data from a given 388 | * array. 389 | * 390 | * array($array) 395 | * ->containsValues(array(1, 2, 3)) // succeed 396 | * ->containsValues(array('5', '8', '13')) // succeed 397 | * ->containsValues(array(0, 1, 2)) // failed 398 | * ; 399 | * 400 | * Note: "containsValues" doesn't search recursively. 401 | * 402 | * to check their types, use strictlyContainsValues. 403 | * 404 | * @param mixed[] $values 405 | * @param string $failMessage 406 | * 407 | * @link http://docs.atoum.org/en/latest/asserters.html#containsvalues 408 | * 409 | * @return $this 410 | */ 411 | public function containsValues(array $values, $failMessage = null) {} 412 | 413 | /** 414 | * "strictlyContainsValues" checks that an array contains all given data 415 | * (same value and same type). 416 | * 417 | * array($array) 422 | * ->strictlyContainsValues(array('1', 2, '3')) // passes 423 | * ->strictlyContainsValues(array(1, 2, 3)) // fails 424 | * ->strictlyContainsValues(array(5, '8', 13)) // passes 425 | * ->strictlyContainsValues(array('5', '8', '13')) // fails 426 | * ->strictlyContainsValues(array(0, '1', 2)) // fails 427 | * ; 428 | * 429 | * Note: "strictlyContainsValue" doesn't search recursively. 430 | * 431 | * to check the types, use containsValues. 432 | * 433 | * @param mixed[] $values 434 | * @param string $failMessage 435 | * 436 | * @link http://docs.atoum.org/en/latest/asserters.html#strictlycontainsvalues 437 | * 438 | * @return $this 439 | */ 440 | public function strictlyContainsValues(array $values, $failMessage = null) {} 441 | 442 | /** 443 | * "notContainsValues" checks that an array doesn't contains any data 444 | * from a given array. 445 | * 446 | * array($array) 451 | * ->notContainsValues(array(1, 4, 10)) // fails 452 | * ->notContainsValues(array(4, 10, 34)) // passes 453 | * ->notContainsValues(array(1, '2', 3)) // fails 454 | * ; 455 | * 456 | * Note: "notContainsValues" doesn't search recursively. 457 | * 458 | * also want to check their types, use strictlyNotContainsValues. 459 | * 460 | * @param mixed[] $values 461 | * @param string $failMessage 462 | * 463 | * @link http://docs.atoum.org/en/latest/asserters.html#notcontainsvalues 464 | * 465 | * @return $this 466 | */ 467 | public function notContainsValues(array $values, $failMessage = null) {} 468 | 469 | /** 470 | * "strictlyNotContainsValues" checks that an array doesn't contains any 471 | * of given data (same value and same type). 472 | * 473 | * array($array) 478 | * ->strictlyNotContainsValues(array('1', 4, 10)) // fails 479 | * ->strictlyNotContainsValues(array(1, 4, 10)) // passes 480 | * ->strictlyNotContainsValues(array(4, 10, 34)) // passes 481 | * ->strictlyNotContainsValues(array('1', 2, '3')) // fails 482 | * ->strictlyNotContainsValues(array(1, '2', 3)) // passes 483 | * ; 484 | * 485 | * Note: "strictlyNotContainsValues" doesn't search recursively. 486 | * 487 | * want to check the types, use notContainsValues. 488 | * 489 | * @param mixed[] $values 490 | * @param string $failMessage 491 | * 492 | * @link http://docs.atoum.org/en/latest/asserters.html#strictlynotcontainsvalues 493 | * 494 | * @return $this 495 | */ 496 | public function strictlyNotContainsValues(array $values, $failMessage = null) {} 497 | 498 | /** 499 | * @param mixed $offset 500 | * 501 | * @return boolean 502 | */ 503 | public function offsetExists($offset) {} 504 | 505 | /** 506 | * @param mixed $offset 507 | * 508 | * @return asserter 509 | */ 510 | public function offsetGet($offset) {} 511 | 512 | /** 513 | * @param mixed $offset 514 | * @param mixed $value 515 | * 516 | * @return void 517 | */ 518 | public function offsetSet($offset, $value) {} 519 | 520 | /** 521 | * @param mixed $offset 522 | * 523 | * @return void 524 | */ 525 | public function offsetUnset($offset) {} 526 | } 527 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/phpClass.php: -------------------------------------------------------------------------------- 1 | class(get_class($object)) 13 | * 14 | * ->class('\StdClass') 15 | * ; 16 | * 17 | * Note: The keyword "class" is a reserved word in PHP, it wasn't 18 | * possible to create a "class" asserter. It's therefore called 19 | * "phpClass" and an alias "class" has been created. You can meet 20 | * either "->phpClass()" or "->class()". 21 | * 22 | * But it's recommended to only use "->class()". 23 | * 24 | * @method $this extends($class) 25 | * @method $this implements($interface) 26 | */ 27 | class phpClass extends variable 28 | { 29 | /** 30 | * "isAbstract" checks that the class is abstract. 31 | * 32 | * class('\StdClass') 35 | * ->isAbstract() // fails 36 | * ; 37 | * 38 | * @var static 39 | * 40 | * @link http://docs.atoum.org/en/latest/asserters.html#isabstract 41 | */ 42 | public $isAbstract; 43 | 44 | /** 45 | * "isFinal" checks that the class is final. 46 | * 47 | * In this case, we test a non-final class ("StdClass") : 48 | * 49 | * class('\StdClass') 52 | * ->isFinal() // fails 53 | * ; 54 | * 55 | * In this case, the tested class is a final one 56 | * 57 | * testedClass 60 | * ->isFinal() // passes 61 | * ; 62 | * 63 | * $this 64 | * ->testedClass 65 | * ->isFinal // passes too 66 | * ; 67 | * 68 | * @var static 69 | * 70 | * @link http://docs.atoum.org/en/latest/asserters.html#isfinal 71 | */ 72 | public $isFinal; 73 | 74 | /** 75 | * "hasNoParent" checks that the class doesn't inherit from any class. 76 | * 77 | * class('\StdClass') 80 | * ->hasNoParent() // passes 81 | * 82 | * ->class('\FilesystemIterator') 83 | * ->hasNoParent() // fails 84 | * ; 85 | * 86 | * inheritance. "hasNoParent" doesn't check interfaces, only the 87 | * inherited classes. 88 | * 89 | * @var static 90 | * 91 | * @link http://docs.atoum.org/en/latest/asserters.html#hasnoparent 92 | */ 93 | public $hasNoParent; 94 | 95 | /** 96 | * "hasParent" checks that the class inherits from a given class. 97 | * 98 | * class('\StdClass') 101 | * ->hasParent() // fails 102 | * 103 | * ->class('\FilesystemIterator') 104 | * ->hasParent() // passes 105 | * ; 106 | * 107 | * inheritance. "hasParent" doesn't check interfaces, only the 108 | * inherited classes. 109 | * 110 | * @param string $parent 111 | * @param string $failMessage 112 | * 113 | * @link http://docs.atoum.org/en/latest/asserters.html#hasparent 114 | * 115 | * @return $this 116 | */ 117 | public function hasParent($parent, $failMessage = null) {} 118 | 119 | /** 120 | * "hasNoParent" checks that the class doesn't inherit from any class. 121 | * 122 | * class('\StdClass') 125 | * ->hasNoParent() // passes 126 | * 127 | * ->class('\FilesystemIterator') 128 | * ->hasNoParent() // fails 129 | * ; 130 | * 131 | * inheritance. "hasNoParent" doesn't check interfaces, only the 132 | * inherited classes. 133 | * 134 | * @param string $failMessage 135 | * 136 | * @link * @link http://docs.atoum.org/en/latest/asserters.html#hasnoparent 137 | * 138 | * @return $this 139 | * 140 | */ 141 | public function hasNoParent($failMessage = null) {} 142 | 143 | /** 144 | * "isSubclassOf" checks that the tested class inherit from given class. 145 | * 146 | * class('\FilesystemIterator') 149 | * ->isSubclassOf('\DirectoryIterator') // passes 150 | * ->isSubclassOf('\SplFileInfo') // passes 151 | * ->isSubclassOf('\StdClass') // fails 152 | * ; 153 | * 154 | * @param string $parent 155 | * @param string $failMessage 156 | * 157 | * @link http://docs.atoum.org/en/latest/asserters.html#issubclassof 158 | * 159 | * @return $this 160 | */ 161 | public function isSubClassOf($parent, $failMessage = null) {} 162 | 163 | /** 164 | * "hasInterface" checks that the class implements a given interface. 165 | * 166 | * class('\ArrayIterator') 169 | * ->hasInterface('Countable') // passes 170 | * 171 | * ->class('\StdClass') 172 | * ->hasInterface('Countable') // fails 173 | * ; 174 | * 175 | * @param string $interface 176 | * @param string $failMessage 177 | * 178 | * @link http://docs.atoum.org/en/latest/asserters.html#hasinterface 179 | * 180 | * @return $this 181 | */ 182 | public function hasInterface($interface, $failMessage = null) {} 183 | 184 | /** 185 | * "isAbstract" checks that the class is abstract. 186 | * 187 | * class('\StdClass') 190 | * ->isAbstract() // fails 191 | * ; 192 | * 193 | * @param string $failMessage 194 | * 195 | * @link http://docs.atoum.org/en/latest/asserters.html#isabstract 196 | * 197 | * @return $this 198 | */ 199 | public function isAbstract($failMessage = null) {} 200 | 201 | /** 202 | * "isFinal" checks that the class is final. 203 | * 204 | * In this case, we test a non-final class ("StdClass") : 205 | * 206 | * class('\StdClass') 209 | * ->isFinal() // fails 210 | * ; 211 | * 212 | * In this case, the tested class is a final one 213 | * 214 | * testedClass 217 | * ->isFinal() // passes 218 | * ; 219 | * 220 | * $this 221 | * ->testedClass 222 | * ->isFinal // passes too 223 | * ; 224 | * 225 | * @param string $failMessage 226 | * 227 | * @link http://docs.atoum.org/en/latest/asserters.html#isfinal 228 | * 229 | * @return $this 230 | */ 231 | public function isFinal($failMessage = null) {} 232 | 233 | /** 234 | * "hasMethod" checks that the class contains a given method. 235 | * 236 | * class('\ArrayIterator') 239 | * ->hasMethod('count') // passes 240 | * 241 | * ->class('\StdClass') 242 | * ->hasMethod('count') // fails 243 | * ; 244 | * 245 | * @param string $method 246 | * @param string $failMessage 247 | * 248 | * @link http://docs.atoum.org/en/latest/asserters.html#hasmethod 249 | * 250 | * @return $this 251 | */ 252 | public function hasMethod($method, $failMessage = null) {} 253 | 254 | /** 255 | * "hasConstant" checks that the class has the tested constant. 256 | * 257 | * class('\StdClass') 260 | * ->hasConstant('FOO') // fails 261 | * 262 | * ->class('\FilesystemIterator') 263 | * ->hasConstant('CURRENT_AS_PATHNAME') // passes 264 | * ; 265 | * 266 | * @param string $constant 267 | * @param string $failMessage 268 | * 269 | * @link http://docs.atoum.org/en/latest/asserters.html#hasconstant 270 | * 271 | * @return $this 272 | */ 273 | public function hasConstant($constant, $failMessage = null) {} 274 | } 275 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/phpFloat.php: -------------------------------------------------------------------------------- 1 | float($float) 40 | * ->isNearlyEqualTo(0.03) // passes 41 | * ->isEqualTo(0.03) // fails 42 | * ; 43 | * 44 | * Note: For more information about the algorithm used, see the 45 | * floating point guide. 46 | * 47 | * @param float $value 48 | * @param float $epsilon 49 | * @param string $failMessage 50 | * 51 | * @link http://docs.atoum.org/en/latest/asserters.html#isnearlyequalto 52 | * 53 | * @return $this 54 | */ 55 | public function isNearlyEqualTo($value, $epsilon = null, $failMessage = null) {} 56 | } 57 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/phpFunction.php: -------------------------------------------------------------------------------- 1 | object($object) 56 | * ->isInstanceOf('\StdClass') // passes 57 | * ->isInstanceOf('\Iterator') // fails 58 | * ; 59 | * 60 | * interface FooInterface 61 | * { 62 | * public function foo(); 63 | * } 64 | * 65 | * class FooClass implements FooInterface 66 | * { 67 | * public function foo() 68 | * { 69 | * echo "foo"; 70 | * } 71 | * } 72 | * 73 | * class BarClass extends FooClass 74 | * { 75 | * } 76 | * 77 | * $foo = new FooClass; 78 | * $bar = new BarClass; 79 | * 80 | * $this 81 | * ->object($foo) 82 | * ->isInstanceOf('\FooClass') // passes 83 | * ->isInstanceOf('\FooInterface') // passes 84 | * ->isInstanceOf('\BarClass') // fails 85 | * ->isInstanceOf('\StdClass') // fails 86 | * 87 | * ->object($bar) 88 | * ->isInstanceOf('\FooClass') // passes 89 | * ->isInstanceOf('\FooInterface') // passes 90 | * ->isInstanceOf('\BarClass') // passes 91 | * ->isInstanceOf('\StdClass') // fails 92 | * ; 93 | * 94 | * Note: The name of the classes and the interfaces must be absolute, 95 | * because any namespace imports are ignored. 96 | * 97 | * Hint: Notice that with PHP ">= 5.5" you can use the keyword "class" 98 | * to get the absolute class names, for example 99 | * "$this->object($foo)->isInstanceOf(FooClass::class)". 100 | * 101 | * @param string $value 102 | * @param string $failMessage 103 | * 104 | * @link http://docs.atoum.org/en/latest/asserters.html#object-is-instance-of 105 | * 106 | * @return $this 107 | */ 108 | public function isInstanceOf($value, $failMessage = null) {} 109 | 110 | /** 111 | * "isNotInstanceOf" check that an object is not: 112 | * 113 | * * an instance of the given class, 114 | * 115 | * * a subclass from the given class (abstract or not), 116 | * 117 | * * an instance of class that implements a given interface. 118 | * 119 | * object($object) 124 | * ->isNotInstanceOf('\StdClass') // fail 125 | * ->isNotInstanceOf('\Iterator') // pass 126 | * ; 127 | * 128 | * Note: As for isInstanceOf, the name of the classes and the 129 | * interfaces must be absolute, because any namespace imports are 130 | * ignored. 131 | * 132 | * @param string $value 133 | * @param string $failMessage 134 | * 135 | * @return $this 136 | * 137 | */ 138 | public function isNotInstanceOf($value, $failMessage = null) {} 139 | 140 | /** 141 | * "hasSize" checks the size of an object that implements the interface 142 | * "Countable". 143 | * 144 | * object($countableObject) 149 | * ->hasSize(3) 150 | * ; 151 | * 152 | * @param integer $size 153 | * @param string $failMessage 154 | * 155 | * @link http://docs.atoum.org/en/latest/asserters.html#object-has-size 156 | * 157 | * @return $this 158 | */ 159 | public function hasSize($size, $failMessage = null) {} 160 | 161 | /** 162 | * "isCloneOf" checks an object is clone of a given one, that is the 163 | * objects are equal but are not the same instance. 164 | * 165 | * foo = 'bar'; 171 | * 172 | * $this 173 | * ->object($object1) 174 | * ->isCloneOf($object2) // passes 175 | * ->isCloneOf($object3) // passes 176 | * ->isCloneOf($object4) // fails 177 | * ; 178 | * 179 | * Note: For more details, read the PHP's documentation about comparing 180 | * objects. 181 | * 182 | * @param object $object 183 | * @param string $failMessage 184 | * 185 | * @link http://docs.atoum.org/en/latest/asserters.html#object-is-clone-of 186 | * 187 | * @return $this 188 | */ 189 | public function isCloneOf($object, $failMessage = null) {} 190 | 191 | /** 192 | * "isEmpty" checks the size of an object that implements the "Countable" 193 | * interface is equal to 0. 194 | * 195 | * object($countableObject) 200 | * ->isEmpty() 201 | * ; 202 | * 203 | * Note: "isEmpty" is equivalent to "hasSize(0)". 204 | * 205 | * @param string $failMessage 206 | * 207 | * @link http://docs.atoum.org/en/latest/asserters.html#object-is-empty 208 | * 209 | * @return $this 210 | */ 211 | public function isEmpty($failMessage = null) {} 212 | 213 | /** 214 | * newTestedInstance; 216 | * $this->object($this->testedInstance)->isTestedInstance; 217 | * 218 | * $object = new TestedClass(); 219 | * $this->object($object)->isTestedInstance; // fail 220 | * 221 | * @param string $failMessage 222 | * 223 | * @return $this 224 | */ 225 | public function isTestedInstance($failMessage = null) {} 226 | 227 | /** 228 | * newTestedInstance; 230 | * $this->object($this->testedInstance)->isNotTestedInstance; // fail 231 | * 232 | * @param string $failMessage 233 | * 234 | * @return $this 235 | */ 236 | public function isNotTestedInstance($failMessage = null) {} 237 | 238 | /** 239 | * newTestedInstance; 241 | * $object = new TestedClass(); 242 | * $this->object($this->testedInstance)->isInstanceOfTestedClass; 243 | * $this->object($object)->isInstanceOfTestedClass; 244 | * 245 | * @param string $failMessage 246 | * 247 | * @return $this 248 | */ 249 | public function isInstanceOfTestedClass($failMessage = null) {} 250 | 251 | /** 252 | * The toString assertion casts the object to a string a returns a 253 | * *string* asserter on the casted value. 254 | * 255 | * Example: 256 | * 257 | * object( 260 | * new class { 261 | * public function __toString() 262 | * { 263 | * return 'foo'; 264 | * } 265 | * } 266 | * ) 267 | * ->isIdenticalTo('foo') //fails 268 | * ->toString 269 | * ->isIdenticalTo('foo') //passes 270 | * ; 271 | * 272 | * @return castToString 273 | */ 274 | public function toString() {} 275 | 276 | /** 277 | * @return castToArray 278 | */ 279 | public function toArray() {} 280 | } 281 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/phpResource.php: -------------------------------------------------------------------------------- 1 | string($string) 20 | * ->length 21 | * ->isGreaterThanOrEqualTo(5) 22 | * ; 23 | * 24 | * @var \mageekguy\atoum\stubs\asserters\integer 25 | * 26 | * @link http://docs.atoum.org/en/latest/asserters.html#length 27 | */ 28 | public $length; 29 | 30 | /** 31 | * "isEmpty" checks that the string is empty. 32 | * 33 | * string($emptyString) 39 | * ->isEmpty() // passes 40 | * 41 | * ->string($nonEmptyString) 42 | * ->isEmpty() // fails 43 | * ; 44 | * 45 | * @var static 46 | * 47 | * @link http://docs.atoum.org/en/latest/asserters.html#string-is-empty 48 | */ 49 | public $isEmpty; 50 | 51 | /** 52 | * "isNotEmpty" checks that the string is not empty. 53 | * 54 | * string($emptyString) 60 | * ->isNotEmpty() // fails 61 | * 62 | * ->string($nonEmptyString) 63 | * ->isNotEmpty() // passes 64 | * ; 65 | * 66 | * @var static 67 | * 68 | * @link http://docs.atoum.org/en/latest/asserters.html#string-is-not-empty 69 | */ 70 | public $isNotEmpty; 71 | 72 | /** 73 | * @var castToArray 74 | */ 75 | public $toArray; 76 | 77 | /** 78 | * "isEmpty" checks that the string is empty. 79 | * 80 | * string($emptyString) 86 | * ->isEmpty() // passes 87 | * 88 | * ->string($nonEmptyString) 89 | * ->isEmpty() // fails 90 | * ; 91 | * 92 | * @param string $failMessage 93 | * 94 | * @link http://docs.atoum.org/en/latest/asserters.html#string-is-empty 95 | * 96 | * @return $this 97 | */ 98 | public function isEmpty($failMessage = null) {} 99 | 100 | /** 101 | * "isNotEmpty" checks that the string is not empty. 102 | * 103 | * string($emptyString) 109 | * ->isNotEmpty() // fails 110 | * 111 | * ->string($nonEmptyString) 112 | * ->isNotEmpty() // passes 113 | * ; 114 | * 115 | * @param string $failMessage 116 | * 117 | * @link http://docs.atoum.org/en/latest/asserters.html#string-is-not-empty 118 | * 119 | * @return $this 120 | */ 121 | public function isNotEmpty($failMessage = null) {} 122 | 123 | /** 124 | * Hint: "match" is an alias of the "matches" method. For more 125 | * information, refer to the documentation of string::matches 126 | * 127 | * @param string $pattern 128 | * @param string $failMessage 129 | * 130 | * @return $this 131 | */ 132 | public function match($pattern, $failMessage = null) {} 133 | 134 | /** 135 | * "matches" checks that a regular expression match the tested string. 136 | * 137 | * string($phone) 143 | * ->matches('#^0[1-9]\d{8}$#') 144 | * 145 | * ->string($vdm) 146 | * ->matches("#^Today.*VDM$#") 147 | * ; 148 | * 149 | * @param string $pattern 150 | * @param string $failMessage 151 | * 152 | * @link http://docs.atoum.org/en/latest/asserters.html#string-matches 153 | * 154 | * @return $this 155 | */ 156 | public function matches($pattern, $failMessage = null) {} 157 | 158 | public function notMatches($pattern, $failMessage = null) {} 159 | 160 | /** 161 | * "isEqualToContentsOfFile" checks that the string is equal to the 162 | * content of a file given by its path. 163 | * 164 | * string($string) 167 | * ->isEqualToContentsOfFile('/path/to/file') 168 | * ; 169 | * 170 | * Note: if the file doesn't exist, the test will fails. 171 | * 172 | * @param string $path 173 | * @param string $failMessage 174 | * 175 | * @link http://docs.atoum.org/en/latest/asserters.html#string-is-equal-to-contents-of-file 176 | * 177 | * @return $this 178 | */ 179 | public function isEqualToContentsOfFile($path, $failMessage = null) {} 180 | 181 | /** 182 | * "hasLength" checks the string size. 183 | * 184 | * string($string) 189 | * ->hasLength(11) // passes 190 | * ->hasLength(20) // fails 191 | * ; 192 | * 193 | * @param integer $length 194 | * @param string $failMessage 195 | * 196 | * @link http://docs.atoum.org/en/latest/asserters.html#string-has-length 197 | * 198 | * @return $this 199 | */ 200 | public function hasLength($length, $failMessage = null) {} 201 | 202 | /** 203 | * "hasLengthGreaterThan" checks that the string size is greater that the 204 | * given one. 205 | * 206 | * string($string) 211 | * ->hasLengthGreaterThan(10) // passes 212 | * ->hasLengthGreaterThan(20) // fails 213 | * ; 214 | * 215 | * @param integer $length 216 | * @param string $failMessage 217 | * 218 | * @link http://docs.atoum.org/en/latest/asserters.html#string-has-length-greater-than 219 | * 220 | * @return $this 221 | */ 222 | public function hasLengthGreaterThan($length, $failMessage = null) {} 223 | 224 | /** 225 | * "hasLengthLessThan" checks that the string size is lower that the 226 | * given one. 227 | * 228 | * string($string) 233 | * ->hasLengthLessThan(20) // passes 234 | * ->hasLengthLessThan(10) // fails 235 | * ; 236 | * 237 | * @param integer $length 238 | * @param string $failMessage 239 | * 240 | * @link http://docs.atoum.org/en/latest/asserters.html#string-has-length-less-than 241 | * 242 | * @return $this 243 | */ 244 | public function hasLengthLessThan($length, $failMessage = null) {} 245 | 246 | /** 247 | * "contains" checks that a string contains another given string. 248 | * 249 | * string($string) 254 | * ->contains('ll') // passes 255 | * ->contains(' ') // passes 256 | * ->contains('php') // fails 257 | * ; 258 | * 259 | * @param string $fragment 260 | * @param string $failMessage 261 | * 262 | * @link http://docs.atoum.org/en/latest/asserters.html#string-contains 263 | * 264 | * @return $this 265 | */ 266 | public function contains($fragment, $failMessage = null) {} 267 | 268 | /** 269 | * "notContains" checks that the tested string doesn't contains another 270 | * string. 271 | * 272 | * string($string) 277 | * ->notContains('php') // passes 278 | * ->notContains(';') // passes 279 | * ->notContains('ll') // fails 280 | * ->notContains(' ') // fails 281 | * ; 282 | * 283 | * @param string $fragment 284 | * @param string $failMessage 285 | * 286 | * @link http://docs.atoum.org/en/latest/asserters.html#string-not-contains 287 | * 288 | * @return $this 289 | */ 290 | public function notContains($fragment, $failMessage = null) {} 291 | 292 | /** 293 | * "startWith" checks that the tested string starts with another string. 294 | * 295 | * string($string) 300 | * ->startWith('Hello wo') // passes 301 | * ->startWith('He') // passes 302 | * ->startWith('world') // fails 303 | * ->startWith(' ') // fails 304 | * 305 | * ; 306 | * 307 | * @param string $fragment 308 | * @param string $failMessage 309 | * 310 | * @return $this 311 | */ 312 | public function startWith($fragment, $failMessage = null) {} 313 | 314 | /** 315 | * "notStartWith" checks that the tested string doesn't starts with 316 | * another string. 317 | * 318 | * string($string) 323 | * ->notStartWith('world') // passes 324 | * ->notStartWith(' ') // passes 325 | * ->notStartWith('Hello wo') // fails 326 | * ->notStartWith('He') // fails 327 | * ; 328 | * 329 | * @param string $fragment 330 | * @param string $failMessage 331 | * 332 | * @return $this 333 | */ 334 | public function notStartWith($fragment, $failMessage = null) {} 335 | 336 | /** 337 | * "endWith" checks that a string ends with another given string. 338 | * 339 | * string($string) 344 | * ->endWith('world') // passes 345 | * ->endWith('lo world') // passes 346 | * ->endWith('Hello') // fails 347 | * ->endWith(' ') // fails 348 | * ; 349 | * 350 | * @param string $fragment 351 | * @param string $failMessage 352 | * 353 | * @return $this 354 | */ 355 | public function endWith($fragment, $failMessage = null) {} 356 | 357 | /** 358 | * "notEndWith" checks that the tested string doesn't ends with another 359 | * string. 360 | * 361 | * string($string) 366 | * ->notEndWith('Hello') // passes 367 | * ->notEndWith(' ') // passes 368 | * ->notEndWith('world') // fails 369 | * ->notEndWith('lo world') // fails 370 | * ; 371 | * 372 | * @param string $fragment 373 | * @param string $failMessage 374 | * 375 | * @return $this 376 | */ 377 | public function notEndWith($fragment, $failMessage = null) {} 378 | 379 | /** 380 | * @return castToArray 381 | */ 382 | public function toArray() {} 383 | } 384 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/sizeOf.php: -------------------------------------------------------------------------------- 1 | sizeOf($array) 15 | * ->isEqualTo(3) 16 | * 17 | * ->sizeOf($countableObject) 18 | * ->isGreaterThan(0) 19 | * ; 20 | * 21 | */ 22 | class sizeOf extends integer {} 23 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/stream.php: -------------------------------------------------------------------------------- 1 | ´_. 8 | * 9 | * It's based on atoum virtual filesystem (VFS). A new stream wrapper 10 | * will be registered (starting with "atoum://"). 11 | * 12 | * The mock will create a new file in the VFS and the steam path will be 13 | * accessible via the "getPath" method on the stream controller 14 | * (something like "atoum://mockUniqId"). 15 | * 16 | * @method isWritten isWrited($failMessage) 17 | */ 18 | class stream extends asserter 19 | { 20 | /** 21 | * "isRead" checks if a mocked stream has been read. 22 | * 23 | * given( 26 | * $streamController = \atoum\mock\stream::get(), 27 | * $streamController->file_get_contents = 'myFakeContent' 28 | * ) 29 | * ->if(file_get_contents($streamController->getPath())) 30 | * ->stream($streamController) 31 | * ->isRead() // passe 32 | * ; 33 | * 34 | * $this 35 | * ->given( 36 | * $streamController = \atoum\mock\stream::get(), 37 | * $streamController->file_get_contents = 'myFakeContent' 38 | * ) 39 | * ->if() // we do nothing 40 | * ->stream($streamController) 41 | * ->isRead() // fails 42 | * ; 43 | * 44 | * @param string $failMessage 45 | * 46 | * @link http://docs.atoum.org/en/latest/asserters.html#isread 47 | * 48 | * @return $this 49 | */ 50 | public function isRead($failMessage = null) {} 51 | 52 | /** 53 | * "isWritten" checks if a mocked stream has been written. 54 | * 55 | * given( 58 | * $streamController = \atoum\mock\stream::get(), 59 | * $streamController->file_put_contents = strlen($content = 'myTestContent') 60 | * ) 61 | * ->if(file_put_contents($streamController->getPath(), $content)) 62 | * ->stream($streamController) 63 | * ->isWritten() // passes 64 | * ; 65 | * 66 | * $this 67 | * ->given( 68 | * $streamController = \atoum\mock\stream::get(), 69 | * $streamController->file_put_contents = strlen($content = 'myTestContent') 70 | * ) 71 | * ->if() // we do nothing 72 | * ->stream($streamController) 73 | * ->isWritten() // fails 74 | * ; 75 | * 76 | * @param string $failMessage 77 | * 78 | * @return $this 79 | */ 80 | public function isWritten($failMessage = null) {} 81 | } 82 | -------------------------------------------------------------------------------- /classes/mageekguy/atoum/stubs/asserters/testedClass.php: -------------------------------------------------------------------------------- 1 | variable($false) 20 | * ->isNotFalse() // fails 21 | * 22 | * ->variable($true) 23 | * ->isNotFalse() // succeed 24 | * ; 25 | * 26 | * @var static 27 | */ 28 | public $isNotFalse; 29 | 30 | /** 31 | * "isNotNull" checks that the variable is not null. 32 | * 33 | * variable($emptyString) 39 | * ->isNotNull() // passes (it's empty but not null) 40 | * 41 | * ->variable($null) 42 | * ->isNotNull() // fails 43 | * ; 44 | * 45 | * @var static 46 | * 47 | * @link http://docs.atoum.org/en/latest/asserters.html#isnotnull 48 | */ 49 | public $isNotNull; 50 | 51 | /** 52 | * "isNotTrue" check that the variable is strictly not equal to "true". 53 | * 54 | * variable($true) 59 | * ->isNotTrue() // fails 60 | * 61 | * ->variable($false) 62 | * ->isNotTrue() // succeed 63 | * ; 64 | * 65 | * @var static 66 | */ 67 | public $isNotTrue; 68 | 69 | /** 70 | * "isNull" checks that the variable is null. 71 | * 72 | * variable($emptyString) 78 | * ->isNull() // fails 79 | * // (it's empty but not null) 80 | * 81 | * ->variable($null) 82 | * ->isNull() // passes 83 | * ; 84 | * 85 | * @var static 86 | * 87 | * @link http://docs.atoum.org/en/latest/asserters.html#isnull 88 | */ 89 | public $isNull; 90 | 91 | /** 92 | * "isEqualTo" verifies that the variable is equal to a given value. 93 | * 94 | * variable($a) 99 | * ->isEqualTo('a') // passes 100 | * ; 101 | * 102 | * want to check the type, use isIdenticalTo. 103 | * 104 | * @param mixed $value 105 | * @param string $failMessage 106 | * 107 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-equal-to 108 | * 109 | * @return $this 110 | */ 111 | public function isEqualTo($value, $failMessage = null) {} 112 | 113 | /** 114 | * "isNotEqualTo" checks that the variable does not have the same value 115 | * as the given one. 116 | * 117 | * variable($a) 123 | * ->isNotEqualTo('b') // passes 124 | * ->isNotEqualTo('a') // fails 125 | * 126 | * ->variable($aString) 127 | * ->isNotEqualTo($a) // fails 128 | * ; 129 | * 130 | * also want to check the type, use isNotIdenticalTo. 131 | * 132 | * @param mixed $value 133 | * @param string $failMessage 134 | * 135 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-not-equal-to 136 | * 137 | * @return $this 138 | */ 139 | public function isNotEqualTo($value, $failMessage = null) {} 140 | 141 | /** 142 | * "isIdenticalTo" checks that the variable has the same value and the 143 | * same type than the given data. In the case of an object, 144 | * "isIdenticalTo" checks that the data is referencing the same instance. 145 | * 146 | * variable($a) 151 | * ->isIdenticalTo(1) // fails 152 | * ; 153 | * 154 | * $stdClass1 = new \StdClass(); 155 | * $stdClass2 = new \StdClass(); 156 | * $stdClass3 = $stdClass1; 157 | * 158 | * $this 159 | * ->variable($stdClass1) 160 | * ->isIdenticalTo(stdClass3) // passes 161 | * ->isIdenticalTo(stdClass2) // fails 162 | * ; 163 | * 164 | * want to check its type, use isEqualTo. 165 | * 166 | * @param mixed $value 167 | * @param string $failMessage 168 | * 169 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-identical-to 170 | * 171 | * @return $this 172 | */ 173 | public function isIdenticalTo($value, $failMessage = null) {} 174 | 175 | /** 176 | * "isNotIdenticalTo" checks that the variable does not have the same 177 | * type nor the same value than the given one. 178 | * 179 | * In the case of an object, "isNotIdenticalTo" checks that the data 180 | * isn't referencing on the same instance. 181 | * 182 | * variable($a) 187 | * ->isNotIdenticalTo(1) // passes 188 | * ; 189 | * 190 | * $stdClass1 = new \StdClass(); 191 | * $stdClass2 = new \StdClass(); 192 | * $stdClass3 = $stdClass1; 193 | * 194 | * $this 195 | * ->variable($stdClass1) 196 | * ->isNotIdenticalTo(stdClass2) // passes 197 | * ->isNotIdenticalTo(stdClass3) // fails 198 | * ; 199 | * 200 | * want to check its type, use isNotEqualTo. 201 | * 202 | * @param mixed $value 203 | * @param string $failMessage 204 | * 205 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-not-identical-to 206 | * 207 | * @return $this 208 | */ 209 | public function isNotIdenticalTo($value, $failMessage = null) {} 210 | 211 | /** 212 | * "isNull" checks that the variable is null. 213 | * 214 | * variable($emptyString) 220 | * ->isNull() // fails 221 | * // (it's empty but not null) 222 | * 223 | * ->variable($null) 224 | * ->isNull() // passes 225 | * ; 226 | * 227 | * @param string $failMessage 228 | * 229 | * @link http://docs.atoum.org/en/latest/asserters.html#isnull 230 | * 231 | * @return $this 232 | */ 233 | public function isNull($failMessage = null) {} 234 | 235 | /** 236 | * "isNotNull" checks that the variable is not null. 237 | * 238 | * variable($emptyString) 244 | * ->isNotNull() // passes (it's empty but not null) 245 | * 246 | * ->variable($null) 247 | * ->isNotNull() // fails 248 | * ; 249 | * 250 | * @param string $failMessage 251 | * 252 | * @link http://docs.atoum.org/en/latest/asserters.html#isnotnull 253 | * 254 | * @return $this 255 | */ 256 | public function isNotNull($failMessage = null) {} 257 | 258 | /** 259 | * @param mixed & $value 260 | * @param string $failMessage 261 | * 262 | * @return $this 263 | */ 264 | public function isReferenceTo(& $reference, $failMessage = null) {} 265 | 266 | /** 267 | * "isNotFalse" check that the variable is strictly not equal to "false". 268 | * 269 | * variable($false) 274 | * ->isNotFalse() // fails 275 | * 276 | * ->variable($true) 277 | * ->isNotFalse() // succeed 278 | * ; 279 | * 280 | * @param string $failMessage 281 | * 282 | * @return $this 283 | */ 284 | public function isNotFalse($failMessage = null) {} 285 | 286 | /** 287 | * "isNotTrue" check that the variable is strictly not equal to "true". 288 | * 289 | * variable($true) 294 | * ->isNotTrue() // fails 295 | * 296 | * ->variable($false) 297 | * ->isNotTrue() // succeed 298 | * ; 299 | * 300 | * @param string $failMessage 301 | * 302 | * @return $this 303 | */ 304 | public function isNotTrue($failMessage = null) {} 305 | 306 | /** 307 | * "isCallable" verifies that the variable can be called as a function. 308 | * 309 | * variable($f) 316 | * ->isCallable() // succeed 317 | * 318 | * ->variable('\Vendor\Project\foobar') 319 | * ->isCallable() 320 | * 321 | * ->variable(array('\Vendor\Project\Foo', 'bar')) 322 | * ->isCallable() 323 | * 324 | * ->variable('\Vendor\Project\Foo::bar') 325 | * ->isCallable() 326 | * ; 327 | * 328 | * @param callable $value 329 | * @param string $failMessage 330 | * 331 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-callable 332 | * 333 | * @return $this 334 | */ 335 | public function isCallable(callable $value, $failMessage = null) {} 336 | 337 | /** 338 | * "isNotCallable" checks that the variable can't be called like a 339 | * function. 340 | * 341 | * variable($f) 350 | * ->isNotCallable() // fails 351 | * 352 | * ->variable($int) 353 | * ->isNotCallable() // passes 354 | * 355 | * ->variable($string) 356 | * ->isNotCallable() // passes 357 | * 358 | * ->variable(new StdClass) 359 | * ->isNotCallable() // passes 360 | * ; 361 | * 362 | * @param callable $value 363 | * @param string $failMessage 364 | * 365 | * @link http://docs.atoum.org/en/latest/asserters.html#variable-is-not-callable 366 | * 367 | * @return $this 368 | */ 369 | public function isNotCallable(callable $value, $failMessage = null) {} 370 | } 371 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "atoum/stubs", 3 | "type": "library", 4 | "description": "Stubs for atoum, the simple modern and intuitive unit testing framework for PHP 5.3+", 5 | "keywords": ["TDD","atoum","test","unit testing"], 6 | "homepage": "http://www.atoum.org", 7 | "license": "BSD-3-Clause", 8 | "authors": 9 | [ 10 | { 11 | "name": "Julien Bianchi", 12 | "email": "julien.bianchi@atoum.org" 13 | }, 14 | { 15 | "name": "Ludovic Fleury", 16 | "email": "ludovic.fleury@atoum.org" 17 | } 18 | ], 19 | "suggest": { 20 | "atoum/atoum": "Include atoum in your projet dependencies" 21 | }, 22 | "extra": { 23 | "branch-alias": { 24 | "dev-master": "2.x-dev" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atoum/stubs/fb8890f347a7ecf1e3cf2b5a139a8b038359a6ab/demo.gif -------------------------------------------------------------------------------- /src/asserters.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'asserter.php', 8 | 'variable.php', 9 | 'boolean.php', 10 | 'phpObject.php', 11 | 'dateInterval.php', 12 | 'dateTime.php', 13 | 'error.php', 14 | 'exception.php', 15 | 'phpString.php', 16 | 'hash.php', 17 | 'integer.php', 18 | 'phpArray.php', 19 | 'phpClass.php', 20 | 'phpFloat.php', 21 | 'adapter.php', 22 | 'mock.php', 23 | 'mysqlDateTime.php', 24 | 'castToString.php', 25 | 'sizeOf.php', 26 | 'stream.php', 27 | 'utf8String.php', 28 | 'output.php', 29 | 'iterator.php', 30 | 'generator.php', 31 | 'castToArray.php', 32 | 'testedClass.php', 33 | 'phpResource.php', 34 | 'phpFunction.php', 35 | 'extension.php', 36 | 'constant.php', 37 | ], 38 | ]; 39 | -------------------------------------------------------------------------------- /src/functions.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | [], 8 | 'level2' => [], 9 | ]; 10 | $previousLine = null; 11 | $currentAsserter = null; 12 | $currentMethod = null; 13 | $level3Name = null; 14 | foreach (new \SplFileObject($filename) as $line) 15 | { 16 | $line = rtrim($line); 17 | if (preg_match('/^[=]+$/', $line)) 18 | { 19 | $currentAsserter = strtolower($previousLine); 20 | $helps[ 'level1' ][ $currentAsserter ] = [ 21 | 'content' => '', 22 | 'level2' => [ 23 | $currentMethod => [ 24 | 'content' => '', 25 | ], 26 | ], 27 | ]; 28 | 29 | $previousLine = $line; 30 | $level3Name = null; 31 | $currentMethod = null; 32 | continue; 33 | } 34 | 35 | if (preg_match('/^[-]+$/', $line)) 36 | { 37 | $currentMethod = strtolower($previousLine); 38 | $helps[ 'level1' ][ $currentAsserter ][ 'level2' ][ $currentMethod ][ 'content' ] = ''; 39 | $previousLine = $line; 40 | $level3Name = null; 41 | continue; 42 | } 43 | 44 | if (preg_match('/^[~]+$/', $line)) 45 | { 46 | $level3Name = strtolower($previousLine); 47 | $helps[ 'level1' ][ $currentAsserter ][ 'level2' ][ $currentMethod ][ 'level3' ][ $level3Name ][ 'content' ] = ''; 48 | $previousLine = $line; 49 | continue; 50 | } 51 | 52 | if (null !== $currentAsserter) 53 | { 54 | if (null === $currentMethod) 55 | { 56 | $helps[ 'level1' ][ $currentAsserter ][ 'content' ] .= $previousLine . PHP_EOL; 57 | } 58 | else 59 | { 60 | if (null !== $level3Name) 61 | { 62 | $helps[ 'level1' ][ $currentAsserter ][ 'level2' ][ $currentMethod ][ 'level3' ][ $level3Name ][ 'content' ] .= $previousLine . PHP_EOL; 63 | } 64 | else 65 | { 66 | $helps[ 'level1' ][ $currentAsserter ][ 'level2' ][ $currentMethod ][ 'content' ] .= $previousLine . PHP_EOL; 67 | } 68 | } 69 | } 70 | 71 | $previousLine = $line; 72 | } 73 | 74 | if (null !== $currentAsserter && null !== $currentMethod) 75 | { 76 | $helps[ 'level1' ][ $currentAsserter ][ 'level2' ][ $currentMethod ][ 'content' ] .= $previousLine . PHP_EOL; 77 | } 78 | 79 | foreach ($helps[ 'level1' ] as $asserter => $methods) 80 | { 81 | 82 | $explodedHelpLv1Content = explode(PHP_EOL, $methods[ 'content' ]); 83 | $explodedHelpLv1Content = ltrimArray($explodedHelpLv1Content); 84 | $explodedHelpLv1Content = rtrimArray($explodedHelpLv1Content); 85 | $helps[ 'level1' ][ $asserter ][ 'content' ] = implode(PHP_EOL, $explodedHelpLv1Content); 86 | 87 | foreach ($methods[ 'level2' ] as $methodName => $help) 88 | { 89 | $explodedHelp = explode(PHP_EOL, $help[ 'content' ]); 90 | $explodedHelp = ltrimArray($explodedHelp); 91 | $explodedHelp = rtrimArray($explodedHelp); 92 | $helps[ 'level1' ][ $asserter ][ 'level2' ][ $methodName ][ 'content' ] = implode(PHP_EOL, $explodedHelp); 93 | if (isset($helps[ 'level1' ][ $asserter ][ 'level2' ][ $methodName ][ 'level3' ])) 94 | { 95 | foreach ($helps[ 'level1' ][ $asserter ][ 'level2' ][ $methodName ][ 'level3' ] as $level3Name => $helpLvl3) 96 | { 97 | $explodedHelp = explode(PHP_EOL, $helpLvl3[ 'content' ]); 98 | $explodedHelp = ltrimArray($explodedHelp); 99 | $explodedHelp = rtrimArray($explodedHelp); 100 | $helps[ 'level1' ][ $asserter ][ 'level2' ][ $methodName ][ 'level3' ][ $level3Name ][ 'content' ] = implode(PHP_EOL, $explodedHelp); 101 | } 102 | } 103 | } 104 | } 105 | 106 | return $helps; 107 | } 108 | 109 | function ltrimArray(array $array) 110 | { 111 | $tmpArray = []; 112 | $isArrayBegin = true; 113 | foreach ($array as $line) 114 | { 115 | if ($isArrayBegin && (preg_match('/^[-~=]+$/', $line) || 0 === strlen(trim($line)))) 116 | { 117 | continue; 118 | } 119 | $isArrayBegin = false; 120 | $tmpArray[] = $line; 121 | } 122 | 123 | return $tmpArray; 124 | } 125 | 126 | function rtrimArray(array $array) 127 | { 128 | return array_reverse(ltrimArray(array_reverse($array))); 129 | } 130 | 131 | function getLevel2Content(array $helps, $level1Name, $level2Name) 132 | { 133 | if (!isset($helps[ 'level1' ][ $level1Name ][ 'level2' ][ $level2Name ])) 134 | { 135 | throw new \RuntimeException(sprintf('Class : %s, Method %s. Documentation not found', $level1Name, $level2Name)); 136 | } 137 | 138 | return $helps[ 'level1' ][ $level1Name ][ 'level2' ][ $level2Name ][ 'content' ]; 139 | } 140 | 141 | function getMethodHelp(\ReflectionMethod $method, array $helps) 142 | { 143 | $shortClassname = strtolower($method->getDeclaringClass()->getShortName()); 144 | $methodName = strtolower($method->getName()); 145 | 146 | return getLevel2Content($helps, $shortClassname, $methodName); 147 | } 148 | 149 | function getPropertyHelp(\ReflectionProperty $property, array $helps) 150 | { 151 | $shortClassname = strtolower($property->getDeclaringClass()->getShortName()); 152 | $methodName = strtolower($property->getName()); 153 | 154 | return getLevel2Content($helps, $shortClassname, $methodName); 155 | } 156 | 157 | function getClassHelp(\ReflectionClass $class, array $helps) 158 | { 159 | $shortClassname = strtolower($class->getShortName()); 160 | 161 | if (!isset($helps[ 'level1' ][ $shortClassname ])) 162 | { 163 | throw new \RuntimeException(sprintf('Class : %s. Documentation not found', $shortClassname)); 164 | } 165 | 166 | return $helps[ 'level1' ][ $shortClassname ][ 'content' ]; 167 | } 168 | 169 | function applyMappings(array $helps) 170 | { 171 | $helps[ 'level1' ][ 'phpstring' ] = $helps[ 'level1' ][ 'string' ]; 172 | $helps[ 'level1' ][ 'phparray' ] = $helps[ 'level1' ][ 'array' ]; 173 | $helps[ 'level1' ][ 'phpclass' ] = $helps[ 'level1' ][ 'class' ]; 174 | $helps[ 'level1' ][ 'phpfloat' ] = $helps[ 'level1' ][ 'float' ]; 175 | $helps[ 'level1' ][ 'adapter' ] = array_merge($helps[ 'level1' ][ 'mock' ][ 'level2' ][ 'call' ], $helps[ 'level1' ][ 'mock' ]); 176 | $helps[ 'level1' ][ 'adapter' ][ 'level2' ] = array_merge($helps[ 'level1' ][ 'adapter' ][ 'level2' ], $helps[ 'level1' ][ 'adapter' ][ 'level3' ]); 177 | unset($helps[ 'level1' ][ 'adapter' ][ 'level3' ]); 178 | $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'once' ] = $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'once/twice/thrice' ]; 179 | $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'twice' ] = $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'once/twice/thrice' ]; 180 | $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'thrice' ] = $helps[ 'level1' ][ 'adapter' ][ 'level2' ][ 'once/twice/thrice' ]; 181 | 182 | return $helps; 183 | } 184 | 185 | function replaceHelpDoc($docComment, $spacesCount, \closure $helpCallback) 186 | { 187 | $docComment = explode(PHP_EOL, $docComment); 188 | $firstAnnotation = 0; 189 | 190 | foreach ($docComment as $k => $comment) 191 | { 192 | if (preg_match('/^\s+\*\s+@/', $comment) || (preg_match('/^\s+\*\//', $comment))) 193 | { 194 | $firstAnnotation = $k; 195 | 196 | break; 197 | } 198 | } 199 | 200 | try 201 | { 202 | $methodHelpLines = explode(PHP_EOL, $helpCallback()); 203 | $methodHelpLines[] = ''; 204 | } 205 | catch (\RuntimeException $e) 206 | { 207 | return implode(PHP_EOL, $docComment); 208 | } 209 | 210 | if (count($methodHelpLines) === 1 && $methodHelpLines[ 0 ] == '') 211 | { 212 | return implode(PHP_EOL, $docComment); 213 | } 214 | 215 | $methodHelp = ''; 216 | foreach ($methodHelpLines as $methodHelpLine) 217 | { 218 | $methodHelpLine = preg_replace('/^.. (\w+)::/', '$1: ', $methodHelpLine); 219 | $methodHelpLine = preg_replace('/:ref:`(\w+) <.*?>`/', '$1', $methodHelpLine); 220 | 221 | if (preg_match('/^\s*..\s+[\w\-]+:/', $methodHelpLine)) 222 | { 223 | continue; 224 | } 225 | 226 | if (preg_match('/^\s+\|\s/', $methodHelpLine)) 227 | { 228 | $methodHelpLine = ltrim($methodHelpLine, ' |'); 229 | } 230 | 231 | $methodHelp .= str_repeat(' ', $spacesCount) . '* ' . rtrim($methodHelpLine) . PHP_EOL; 232 | } 233 | 234 | $methodHelp = preg_replace('/(?:\s{' . $spacesCount . '}\*\s*\n)+/', str_repeat(' ', $spacesCount) . '*' . PHP_EOL, $methodHelp); 235 | $methodHelp = rtrim($methodHelp); 236 | 237 | $doc = '/**' . PHP_EOL; 238 | $doc .= $methodHelp; 239 | $doc .= $methodHelp !== '' ? PHP_EOL : ''; 240 | $doc .= implode(PHP_EOL, array_slice($docComment, $firstAnnotation)); 241 | 242 | return $doc; 243 | } 244 | 245 | function replaceInFile($file, $docComment, $newDocComment, $suffix) 246 | { 247 | return file_put_contents( 248 | $file, 249 | preg_replace_callback( 250 | sprintf('/(%s)([\w\s]+%s)/msi', preg_quote($docComment, '/'), preg_quote($suffix, '/s')), 251 | function($matches) use ($newDocComment) 252 | { 253 | return $newDocComment . $matches[ 2 ]; 254 | }, 255 | file_get_contents($file) 256 | ) 257 | ); 258 | } 259 | 260 | function updateFile($file, $className, array $helps) 261 | { 262 | $refectionClass = new \ReflectionClass($className); 263 | foreach ($refectionClass->getMethods() as $method) 264 | { 265 | if ($className != $method->getDeclaringClass()->getName()) 266 | { 267 | continue; 268 | } 269 | 270 | if (strtolower($method->getName()) == 'isreferenceto') 271 | { 272 | continue; 273 | } 274 | 275 | $newDocComment = replaceHelpDoc( 276 | $method->getDocComment(), 277 | 5, 278 | function() use ($helps, $method) 279 | { 280 | return getMethodHelp($method, $helps); 281 | } 282 | ); 283 | 284 | replaceInFile($file, $method->getDocComment(), $newDocComment, 'function ' . $method->getName() . "("); 285 | } 286 | 287 | foreach ($refectionClass->getProperties() as $property) 288 | { 289 | if ($className != $property->getDeclaringClass()->getName()) 290 | { 291 | continue; 292 | } 293 | 294 | $newPropertyDocComment = replaceHelpDoc( 295 | $property->getDocComment(), 296 | 5, 297 | function() use ($helps, $property) 298 | { 299 | return getPropertyHelp($property, $helps); 300 | } 301 | ); 302 | 303 | replaceInFile($file, $property->getDocComment(), $newPropertyDocComment, 'public $' . $property->getName() . ";"); 304 | } 305 | 306 | if (false !== $refectionClass->getDocComment()) 307 | { 308 | $newClassDocComment = replaceHelpDoc( 309 | $refectionClass->getDocComment(), 310 | 1, 311 | function() use ($helps, $refectionClass) 312 | { 313 | return getClassHelp($refectionClass, $helps); 314 | } 315 | ); 316 | replaceInFile($file, $refectionClass->getDocComment(), $newClassDocComment, $refectionClass->getShortName()); 317 | } 318 | } 319 | 320 | function createNewStubClass($className, $namespace) 321 | { 322 | $content = <<