├── .travis.yml ├── ABOUT ├── CC.md ├── CHANGELOG.md ├── COPYING ├── CREDITS.md ├── FAQ.md ├── README.md ├── bin └── atoum ├── classes ├── adapter.php ├── adapter │ └── definition.php ├── annotations │ └── extractor.php ├── asserter.php ├── asserter │ ├── definition.php │ ├── exception.php │ ├── generator.php │ └── resolver.php ├── asserters │ ├── adapter.php │ ├── adapter │ │ ├── call.php │ │ ├── call │ │ │ ├── exceptions │ │ │ │ └── logic.php │ │ │ ├── manager.php │ │ │ └── manager │ │ │ │ └── exception.php │ │ └── exceptions │ │ │ └── logic.php │ ├── boolean.php │ ├── castToString.php │ ├── constant.php │ ├── dateInterval.php │ ├── dateTime.php │ ├── error.php │ ├── exception.php │ ├── extension.php │ ├── float.php │ ├── hash.php │ ├── integer.php │ ├── mock.php │ ├── mock │ │ └── exceptions │ │ │ └── logic.php │ ├── mysqlDateTime.php │ ├── object.php │ ├── output.php │ ├── phpArray.php │ ├── phpClass.php │ ├── phpFunction.php │ ├── sizeOf.php │ ├── stream.php │ ├── string.php │ ├── testedClass.php │ ├── utf8String.php │ └── variable.php ├── autoloader.php ├── autoloader │ └── mock.php ├── cli.php ├── cli │ ├── clear.php │ ├── colorizer.php │ ├── command.php │ ├── command │ │ └── exception.php │ ├── commands │ │ └── git.php │ ├── progressBar.php │ └── prompt.php ├── configurator.php ├── exception.php ├── exceptions │ ├── logic.php │ ├── logic │ │ ├── badMethodCall.php │ │ └── invalidArgument.php │ ├── runtime.php │ └── runtime │ │ ├── file.php │ │ └── unexpectedValue.php ├── extension.php ├── factory │ ├── builder.php │ └── builder │ │ └── closure.php ├── fs │ ├── path.php │ └── path │ │ ├── exception.php │ │ └── factory.php ├── includer.php ├── includer │ └── exception.php ├── iterators │ ├── filters │ │ └── recursives │ │ │ ├── atoum │ │ │ └── source.php │ │ │ ├── closure.php │ │ │ ├── dot.php │ │ │ └── extension.php │ └── recursives │ │ ├── atoum │ │ └── source.php │ │ └── directory │ │ └── factory.php ├── locale.php ├── mailer.php ├── mailers │ └── mail.php ├── mock │ ├── aggregator.php │ ├── controller.php │ ├── controller │ │ ├── invoker.php │ │ ├── iterator.php │ │ └── linker.php │ ├── generator.php │ ├── generator │ │ └── method │ │ │ └── exception.php │ ├── php │ │ ├── method.php │ │ └── method │ │ │ └── argument.php │ ├── stream.php │ ├── stream │ │ ├── controller.php │ │ └── invoker.php │ └── streams │ │ └── fs │ │ ├── controller.php │ │ ├── controller │ │ └── factory.php │ │ ├── directory.php │ │ ├── directory │ │ └── controller.php │ │ ├── file.php │ │ └── file │ │ └── controller.php ├── observable.php ├── observer.php ├── observers │ ├── runner.php │ └── test.php ├── php.php ├── php │ ├── call.php │ ├── exception.php │ ├── mocker.php │ ├── mocker │ │ ├── adapter.php │ │ └── adapter │ │ │ └── invoker.php │ ├── tokenizer.php │ └── tokenizer │ │ ├── iterator.php │ │ ├── iterator │ │ └── value.php │ │ ├── iterators │ │ ├── phpArgument.php │ │ ├── phpClass.php │ │ ├── phpConstant.php │ │ ├── phpDefaultValue.php │ │ ├── phpFunction.php │ │ ├── phpImportation.php │ │ ├── phpMethod.php │ │ ├── phpNamespace.php │ │ ├── phpProperty.php │ │ └── phpScript.php │ │ └── token.php ├── reader.php ├── readers │ └── std │ │ └── in.php ├── report.php ├── report │ ├── field.php │ ├── fields │ │ ├── event.php │ │ ├── runner.php │ │ ├── runner │ │ │ ├── atoum.php │ │ │ ├── atoum │ │ │ │ ├── cli.php │ │ │ │ ├── logo.php │ │ │ │ └── phing.php │ │ │ ├── coverage.php │ │ │ ├── coverage │ │ │ │ ├── cli.php │ │ │ │ ├── html.php │ │ │ │ └── treemap.php │ │ │ ├── duration.php │ │ │ ├── duration │ │ │ │ ├── cli.php │ │ │ │ └── phing.php │ │ │ ├── errors.php │ │ │ ├── errors │ │ │ │ └── cli.php │ │ │ ├── event.php │ │ │ ├── event │ │ │ │ ├── cli.php │ │ │ │ ├── nyancat.php │ │ │ │ └── santa.php │ │ │ ├── exceptions.php │ │ │ ├── exceptions │ │ │ │ └── cli.php │ │ │ ├── failures.php │ │ │ ├── failures │ │ │ │ ├── cli.php │ │ │ │ ├── execute.php │ │ │ │ └── execute │ │ │ │ │ ├── macos │ │ │ │ │ ├── macvim.php │ │ │ │ │ └── phpstorm.php │ │ │ │ │ └── unix │ │ │ │ │ ├── gedit.php │ │ │ │ │ ├── gvim.php │ │ │ │ │ └── phpstorm.php │ │ │ ├── outputs.php │ │ │ ├── outputs │ │ │ │ └── cli.php │ │ │ ├── php │ │ │ │ ├── path.php │ │ │ │ ├── path │ │ │ │ │ └── cli.php │ │ │ │ ├── version.php │ │ │ │ └── version │ │ │ │ │ └── cli.php │ │ │ ├── result.php │ │ │ ├── result │ │ │ │ ├── cli.php │ │ │ │ ├── logo.php │ │ │ │ ├── notifier.php │ │ │ │ └── notifier │ │ │ │ │ ├── image.php │ │ │ │ │ ├── image │ │ │ │ │ ├── growl.php │ │ │ │ │ └── libnotify.php │ │ │ │ │ └── terminal.php │ │ │ ├── tap │ │ │ │ └── plan.php │ │ │ └── tests │ │ │ │ ├── coverage.php │ │ │ │ ├── coverage │ │ │ │ ├── cli.php │ │ │ │ └── phing.php │ │ │ │ ├── duration.php │ │ │ │ ├── duration │ │ │ │ └── cli.php │ │ │ │ ├── memory.php │ │ │ │ ├── memory │ │ │ │ ├── cli.php │ │ │ │ └── phing.php │ │ │ │ ├── skipped.php │ │ │ │ ├── skipped │ │ │ │ └── cli.php │ │ │ │ ├── uncompleted.php │ │ │ │ ├── uncompleted │ │ │ │ └── cli.php │ │ │ │ ├── void.php │ │ │ │ └── void │ │ │ │ └── cli.php │ │ └── test │ │ │ ├── duration.php │ │ │ ├── duration │ │ │ ├── cli.php │ │ │ └── phing.php │ │ │ ├── event.php │ │ │ ├── event │ │ │ ├── cli.php │ │ │ ├── phing.php │ │ │ └── tap.php │ │ │ ├── memory.php │ │ │ ├── memory │ │ │ ├── cli.php │ │ │ └── phing.php │ │ │ ├── run.php │ │ │ └── run │ │ │ ├── cli.php │ │ │ └── phing.php │ └── writers │ │ ├── asynchronous.php │ │ └── realtime.php ├── reports │ ├── asynchronous.php │ ├── asynchronous │ │ ├── builder.php │ │ ├── clover.php │ │ ├── coveralls.php │ │ ├── vim.php │ │ └── xunit.php │ ├── realtime.php │ └── realtime │ │ ├── cli.php │ │ ├── cli │ │ └── light.php │ │ ├── nyancat.php │ │ ├── phing.php │ │ ├── santa.php │ │ └── tap.php ├── runner.php ├── runner │ └── score.php ├── score.php ├── score │ └── coverage.php ├── script.php ├── script │ ├── arguments │ │ └── parser.php │ ├── configurable.php │ └── prompt.php ├── scripts │ ├── builder.php │ ├── builder │ │ ├── vcs.php │ │ └── vcs │ │ │ └── svn.php │ ├── compiler.php │ ├── coverage.php │ ├── git │ │ └── pusher.php │ ├── phar │ │ ├── generator.php │ │ └── stub.php │ ├── runner.php │ ├── tagger.php │ ├── tagger │ │ └── engine.php │ ├── treemap.php │ └── treemap │ │ ├── analyzer.php │ │ ├── analyzer │ │ └── generic.php │ │ ├── analyzers │ │ ├── size.php │ │ ├── sloc.php │ │ └── token.php │ │ └── categorizer.php ├── superglobals.php ├── template.php ├── template │ ├── data.php │ ├── iterator.php │ ├── parser.php │ ├── parser │ │ └── exception.php │ └── tag.php ├── test.php ├── test │ ├── adapter.php │ ├── adapter │ │ ├── call.php │ │ ├── call │ │ │ ├── arguments │ │ │ │ └── decorator.php │ │ │ ├── decorator.php │ │ │ └── decorators │ │ │ │ └── addClass.php │ │ ├── calls.php │ │ ├── calls │ │ │ └── decorator.php │ │ ├── invoker.php │ │ └── storage.php │ ├── asserter │ │ └── generator.php │ ├── assertion │ │ ├── aliaser.php │ │ ├── manager.php │ │ └── manager │ │ │ └── exception.php │ ├── engine.php │ ├── engines │ │ ├── concurrent.php │ │ ├── inline.php │ │ └── isolate.php │ ├── exceptions │ │ ├── runtime.php │ │ ├── skip.php │ │ └── stop.php │ ├── generator.php │ ├── generator │ │ └── exception.php │ ├── mock │ │ └── generator.php │ └── score.php ├── tools │ ├── diff.php │ ├── diff │ │ └── decorator.php │ ├── diffs │ │ └── variable.php │ └── variable │ │ └── analyzer.php ├── writer.php ├── writer │ ├── decorator.php │ └── decorators │ │ ├── eol.php │ │ ├── prompt.php │ │ ├── rtrim.php │ │ └── trim.php └── writers │ ├── file.php │ ├── http.php │ ├── http │ └── exception.php │ ├── mail.php │ ├── std.php │ └── std │ ├── err.php │ └── out.php ├── composer.json ├── constants.php ├── resources ├── configurations │ ├── .gitignore │ ├── builder │ │ └── config.php.dist │ └── runner │ │ ├── atoum.php.dist │ │ ├── bootstrap.php.dist │ │ ├── builder.php.dist │ │ ├── cli.php.dist │ │ ├── clover.php.dist │ │ ├── coverage.php.dist │ │ ├── coveralls.php.dist │ │ ├── logo.php.dist │ │ ├── santa.php.dist │ │ ├── vim.php.dist │ │ └── xunit.php.dist ├── coverage │ └── treemap │ │ └── index.html ├── images │ ├── logo.png │ └── logo │ │ ├── failure.png │ │ └── success.png ├── phing │ ├── AtoumTask.php │ └── build.xml ├── sonar │ └── maven │ │ └── pom.xml ├── templates │ ├── coverage │ │ ├── class.tpl │ │ ├── index.tpl │ │ └── screen.css │ └── test │ │ └── generator │ │ ├── testClass.php │ │ └── testedClass.php ├── treemap │ └── index.html └── vim │ └── atoum.vmb ├── scripts ├── builder.php ├── compiler.php ├── coverage.php ├── git │ ├── .tag │ └── pusher.php ├── phar │ ├── generator.php │ └── resources │ │ └── stub.php ├── runner.php ├── tagger.php └── treemap.php └── tests └── units ├── .atoum.php ├── asserters └── template │ └── parser │ └── exception.php ├── classes ├── adapter.php ├── annotations │ └── extractor.php ├── asserter.php ├── asserter │ ├── generator.php │ └── resolver.php ├── asserters │ ├── adapter.php │ ├── adapter │ │ ├── call.php │ │ ├── call │ │ │ ├── exceptions │ │ │ │ └── logic.php │ │ │ ├── manager.php │ │ │ └── manager │ │ │ │ └── exception.php │ │ └── exceptions │ │ │ └── logic.php │ ├── boolean.php │ ├── castToString.php │ ├── constant.php │ ├── dateInterval.php │ ├── dateTime.php │ ├── error.php │ ├── exception.php │ ├── extension.php │ ├── float.php │ ├── hash.php │ ├── integer.php │ ├── mock.php │ ├── mock │ │ └── exceptions │ │ │ └── logic.php │ ├── mysqlDateTime.php │ ├── object.php │ ├── output.php │ ├── phpArray.php │ ├── phpClass.php │ ├── phpFunction.php │ ├── sizeOf.php │ ├── stream.php │ ├── string.php │ ├── testedClass.php │ ├── utf8String.php │ └── variable.php ├── autoloader.php ├── autoloader │ └── mock.php ├── cli.php ├── cli │ ├── clear.php │ ├── colorizer.php │ ├── command │ │ └── exception.php │ ├── commands │ │ └── git.php │ ├── progressBar.php │ └── prompt.php ├── configurator.php ├── exceptions │ ├── logic.php │ ├── logic │ │ ├── badMethodCall.php │ │ └── invalidArgument.php │ ├── runtime.php │ └── runtime │ │ └── unexpectedValue.php ├── factory │ └── builder │ │ └── closure.php ├── fs │ ├── path.php │ └── path │ │ ├── exception.php │ │ └── factory.php ├── includer.php ├── iterators │ ├── filters │ │ └── recursives │ │ │ ├── atoum │ │ │ └── source.php │ │ │ ├── closure.php │ │ │ ├── dot.php │ │ │ └── extension.php │ └── recursives │ │ ├── atoum │ │ └── source.php │ │ └── directory │ │ └── factory.php ├── locale.php ├── mailers │ └── mail.php ├── mock │ ├── controller.php │ ├── controller │ │ ├── invoker.php │ │ ├── iterator.php │ │ └── linker.php │ ├── generator.php │ ├── generator │ │ └── method │ │ │ └── exception.php │ ├── php │ │ ├── method.php │ │ └── method │ │ │ └── argument.php │ ├── stream.php │ ├── stream │ │ ├── controller.php │ │ └── invoker.php │ └── streams │ │ └── fs │ │ ├── controller.php │ │ ├── controller │ │ └── factory.php │ │ ├── directory.php │ │ ├── directory │ │ └── controller.php │ │ ├── file.php │ │ └── file │ │ └── controller.php ├── php.php ├── php │ ├── exception.php │ ├── mocker.php │ ├── mocker │ │ ├── adapter.php │ │ └── adapter │ │ │ └── invoker.php │ ├── tokenizer.php │ └── tokenizer │ │ ├── iterator.php │ │ ├── iterators │ │ ├── phpArgument.php │ │ ├── phpClass.php │ │ ├── phpConstant.php │ │ ├── phpFunction.php │ │ ├── phpImportation.php │ │ ├── phpMethod.php │ │ ├── phpNamespace.php │ │ ├── phpProperty.php │ │ └── phpScript.php │ │ └── token.php ├── reader.php ├── readers │ └── std │ │ └── in.php ├── report.php ├── report │ ├── field.php │ └── fields │ │ ├── runner │ │ ├── atoum │ │ │ ├── cli.php │ │ │ ├── logo.php │ │ │ └── phing.php │ │ ├── coverage.php │ │ ├── coverage │ │ │ ├── html.php │ │ │ └── treemap.php │ │ ├── duration │ │ │ ├── cli.php │ │ │ └── phing.php │ │ ├── errors │ │ │ └── cli.php │ │ ├── event │ │ │ └── cli.php │ │ ├── exceptions │ │ │ └── cli.php │ │ ├── failures │ │ │ ├── cli.php │ │ │ ├── execute.php │ │ │ └── execute │ │ │ │ ├── macos │ │ │ │ ├── macvim.php │ │ │ │ └── phpstorm.php │ │ │ │ └── unix │ │ │ │ ├── gedit.php │ │ │ │ ├── gvim.php │ │ │ │ └── phpstorm.php │ │ ├── outputs │ │ │ └── cli.php │ │ ├── php │ │ │ ├── path │ │ │ │ └── cli.php │ │ │ └── version │ │ │ │ └── cli.php │ │ ├── result │ │ │ ├── cli.php │ │ │ ├── logo.php │ │ │ ├── notifier.php │ │ │ └── notifier │ │ │ │ ├── image.php │ │ │ │ ├── image │ │ │ │ ├── growl.php │ │ │ │ └── libnotify.php │ │ │ │ └── terminal.php │ │ ├── tap │ │ │ └── plan.php │ │ └── tests │ │ │ ├── coverage │ │ │ ├── cli.php │ │ │ └── phing.php │ │ │ ├── duration │ │ │ └── cli.php │ │ │ ├── memory │ │ │ ├── cli.php │ │ │ └── phing.php │ │ │ ├── skipped.php │ │ │ ├── skipped │ │ │ └── cli.php │ │ │ ├── uncompleted │ │ │ └── cli.php │ │ │ └── void.php │ │ └── test │ │ ├── duration │ │ ├── cli.php │ │ └── phing.php │ │ ├── event │ │ ├── cli.php │ │ ├── phing.php │ │ └── tap.php │ │ ├── memory │ │ ├── cli.php │ │ └── phing.php │ │ └── run │ │ ├── cli.php │ │ └── phing.php ├── reports │ ├── asynchronous.php │ ├── asynchronous │ │ ├── builder.php │ │ ├── clover.php │ │ ├── clover │ │ │ └── resources │ │ │ │ ├── 1.xml │ │ │ │ └── 2.xml │ │ ├── coveralls.php │ │ ├── coveralls │ │ │ └── resources │ │ │ │ ├── 1.json │ │ │ │ ├── 2.json │ │ │ │ └── 3.json │ │ ├── vim.php │ │ ├── xunit.php │ │ └── xunit │ │ │ └── resources │ │ │ ├── 1.xml │ │ │ ├── 2.xml │ │ │ └── 3.xml │ ├── realtime.php │ └── realtime │ │ ├── cli.php │ │ ├── cli │ │ └── light.php │ │ ├── phing.php │ │ └── tap.php ├── runner.php ├── runner │ └── score.php ├── score.php ├── score │ └── coverage.php ├── script.php ├── script │ ├── arguments │ │ └── parser.php │ ├── configurable.php │ └── prompt.php ├── scripts │ ├── builder.php │ ├── builder │ │ └── vcs │ │ │ └── svn.php │ ├── coverage.php │ ├── git │ │ ├── .tag │ │ └── pusher.php │ ├── phar │ │ ├── generator.php │ │ └── stub.php │ ├── runner.php │ ├── tagger.php │ ├── tagger │ │ └── engine.php │ ├── treemap.php │ └── treemap │ │ ├── analyzer │ │ └── generic.php │ │ └── categorizer.php ├── superglobals.php ├── template.php ├── template │ ├── data.php │ ├── iterator.php │ ├── parser.php │ └── tag.php ├── test.php ├── test │ ├── adapter.php │ ├── adapter │ │ ├── call.php │ │ ├── call │ │ │ ├── arguments │ │ │ │ └── decorator.php │ │ │ ├── decorator.php │ │ │ └── decorators │ │ │ │ └── addClass.php │ │ ├── calls.php │ │ ├── calls │ │ │ └── decorator.php │ │ ├── invoker.php │ │ └── storage.php │ ├── assertion │ │ ├── aliaser.php │ │ ├── manager.php │ │ └── manager │ │ │ └── exception.php │ ├── engine.php │ ├── engines │ │ ├── concurrent.php │ │ └── inline.php │ ├── generator.php │ ├── generator │ │ └── exception.php │ ├── mock │ │ └── generator.php │ └── score.php ├── tools │ ├── diff.php │ ├── diff │ │ └── decorator.php │ ├── diffs │ │ └── variable.php │ └── variable │ │ └── analyzer.php ├── writer.php ├── writer │ └── decorators │ │ ├── eol.php │ │ ├── prompt.php │ │ ├── rtrim.php │ │ └── trim.php └── writers │ ├── file.php │ ├── http.php │ ├── mail.php │ ├── std.php │ └── std │ ├── err.php │ └── out.php ├── resources └── phing │ └── AtoumTask.php └── runner.php /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.3 4 | - 5.4 5 | - 5.5 6 | - 5.6 7 | - hhvm 8 | - hhvm-nightly 9 | matrix: 10 | allow_failures: 11 | - php: hhvm 12 | - php: hhvm-nightly 13 | env: 14 | global: 15 | - secure: "vJ1TnFhU9muqLwkiBd13lFqdPJIrwKJ5OJjR3/jQROWQsRO4NPd/I7OfdDKk\noJGYbgjGMw7bmBYI0xjhYfZAnrClwIBvn1Qx5x5UDGxTHC8ZP6xs49AGa37I\n7BJlWC7+nRwPmmLhoLsbut/O7Kkn8IkdJIeChHbdn8RHQIJTJ4Y=" 16 | sudo: false 17 | before_script: 18 | - "[ -n \"$COVERALLS_REPO_TOKEN\" ] && cp resources/configurations/runner/coveralls.php.dist .atoum.php || true" 19 | - "[ -n \"$COVERALLS_REPO_TOKEN\" ] && sed -i s?/path/to/sources/directory?classes? .atoum.php || true" 20 | - "[ -n \"$COVERALLS_REPO_TOKEN\" ] && sed -i s/YouCoverallsProjectToken/$COVERALLS_REPO_TOKEN/ .atoum.php || true" 21 | script: 22 | - php ./scripts/runner.php --test-it 23 | -------------------------------------------------------------------------------- /ABOUT: -------------------------------------------------------------------------------- 1 | atoum is a simple, modern and intuitive PHP 5.3+ unit testing framework. 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014, Frédéric Hardy. 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 | * Neither the name of Frédéric Hardy nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY FRÉDÉRIC HARDY AND CONTRIBUTORS ``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 FRÉDÉRIC HARDY AND CONTRIBUTORS 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 | -------------------------------------------------------------------------------- /CREDITS.md: -------------------------------------------------------------------------------- 1 | #Main contributors 2 | 3 | * Julien Bianchi (julien.bianchi@atoum.org) 4 | * Ludovic Fleury (ludovic.fleury@atoum.org) 5 | * Gérald Croes (gerald.croes@atoum.org) 6 | * François Dussert (francois.dussert@atoum.org) 7 | 8 | #Special thanks 9 | 10 | * Renaud Littolff (renaud.littolff@atoum.org) for the french documentation 11 | * Julien Clauzel (julien.clauzel@atoum.org) 12 | * Gauthier Delamarre (gauthier.delamarre@atoum.org) 13 | * Adrien Gallou (adrien.gallou@atoum.org) 14 | * Mathieu Robin (mthrobin@gmail.com) 15 | * Jérémy Poulain (jerem.poulain@gmail.com) 16 | * Ivan Enderlin (ivan.enderlin@hoa-project.net) 17 | * Stéphane Py (py.stephane1@gmail.com) 18 | * Geoffrey Bachelet (grosfrais@gmail.com) 19 | * Nathanaël Louison (bennetteson@gmail.com) 20 | * Simon Jodet (simon@jodet.com) 21 | 22 | And all all other contributors! 23 | -------------------------------------------------------------------------------- /bin/atoum: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 9 | -------------------------------------------------------------------------------- /classes/adapter.php: -------------------------------------------------------------------------------- 1 | invoke($functionName, $arguments); 14 | } 15 | 16 | public function invoke($functionName, array $arguments = array()) 17 | { 18 | return call_user_func_array($functionName, $arguments); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /classes/adapter/definition.php: -------------------------------------------------------------------------------- 1 | getTest(); 16 | 17 | if ($test !== null) 18 | { 19 | $class = $test->getClass(); 20 | $method = $test->getCurrentMethod(); 21 | $file = $test->getPath(); 22 | $line = null; 23 | $function = null; 24 | 25 | foreach (array_filter(debug_backtrace(false), function($backtrace) use ($file) { return isset($backtrace['file']) === true && $backtrace['file'] === $file; }) as $backtrace) 26 | { 27 | if ($line === null && isset($backtrace['line']) === true) 28 | { 29 | $line = $backtrace['line']; 30 | } 31 | 32 | if ($function === null && isset($backtrace['object']) === true && isset($backtrace['function']) === true && $backtrace['object'] === $asserter && $backtrace['function'] !== '__call') 33 | { 34 | $function = $backtrace['function']; 35 | } 36 | } 37 | 38 | $code = $test->getScore()->addFail($file, $class, $method, $line, get_class($asserter) . ($function ? '::' . $function : '') . '()', $message); 39 | } 40 | 41 | parent::__construct($message, $code); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /classes/asserter/resolver.php: -------------------------------------------------------------------------------- 1 | setBaseClass($baseClass ?: static::defaultBaseClass) 17 | ->addNamespace($namespace ?: static::defaultNamespace) 18 | ; 19 | } 20 | 21 | public function setBaseClass($baseClass) 22 | { 23 | $this->baseClass = trim($baseClass, '\\'); 24 | 25 | return $this; 26 | } 27 | 28 | public function getBaseClass() 29 | { 30 | return $this->baseClass; 31 | } 32 | 33 | public function addNamespace($namespace) 34 | { 35 | $this->namespaces[] = trim($namespace, '\\'); 36 | 37 | return $this; 38 | } 39 | 40 | public function getNamespaces() 41 | { 42 | return $this->namespaces; 43 | } 44 | 45 | public function resolve($asserter) 46 | { 47 | $class = null; 48 | 49 | if (strpos($asserter, '\\') !== false) 50 | { 51 | $class = $this->checkClass($asserter); 52 | } 53 | else foreach ($this->namespaces as $namespace) 54 | { 55 | $class = $this->checkClass($namespace . '\\' . $asserter); 56 | 57 | if ($class !== null) 58 | { 59 | break; 60 | } 61 | } 62 | 63 | return $class; 64 | } 65 | 66 | private function checkClass($class) 67 | { 68 | return (class_exists($class, true) === false || is_subclass_of($class, $this->baseClass) === false ? null : $class); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /classes/asserters/adapter/call/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | calls = new \splObjectStorage(); 16 | } 17 | 18 | public function add(adapter\call $call) 19 | { 20 | $this->calls->attach($call); 21 | 22 | return $this; 23 | } 24 | 25 | public function remove(adapter\call $call) 26 | { 27 | $this->calls->detach($call); 28 | 29 | return $this; 30 | } 31 | 32 | public function check() 33 | { 34 | if (sizeof($this->calls) > 0) 35 | { 36 | $this->calls->rewind(); 37 | 38 | $call = $this->calls->current(); 39 | 40 | throw new manager\exception('Asserter ' . get_class($call) . ' is not evaluated in file \'' . $call->getLastAssertionFile() . '\' on line ' . $call->getLastAssertionLine()); 41 | } 42 | 43 | return $this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/asserters/adapter/call/manager/exception.php: -------------------------------------------------------------------------------- 1 | {$property}(); 19 | 20 | default: 21 | return parent::__get($property); 22 | } 23 | } 24 | 25 | public function setWith($value) 26 | { 27 | parent::setWith($value); 28 | 29 | if ($this->analyzer->isBoolean($this->value) === true) 30 | { 31 | $this->pass(); 32 | } 33 | else 34 | { 35 | $this->fail($this->_('%s is not a boolean', $this)); 36 | } 37 | 38 | return $this; 39 | } 40 | 41 | public function isTrue($failMessage = null) 42 | { 43 | return $this->isEqualTo(true, $failMessage ?: $this->_('%s is not true', $this)); 44 | } 45 | 46 | public function isFalse($failMessage = null) 47 | { 48 | return $this->isEqualTo(false, $failMessage ?: $this->_('%s is not false', $this)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /classes/asserters/castToString.php: -------------------------------------------------------------------------------- 1 | fail($this->_('%s is not an object', $this->getTypeOf($value))); 18 | } 19 | else 20 | { 21 | $this->pass(); 22 | 23 | $this->value = (string) $this->value; 24 | } 25 | } 26 | 27 | return $this; 28 | } 29 | 30 | protected static function isObject($value) 31 | { 32 | return (is_object($value) === true); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /classes/asserters/float.php: -------------------------------------------------------------------------------- 1 | analyzer->isFloat($this->value) === true) 18 | { 19 | $this->pass(); 20 | } 21 | else 22 | { 23 | $this->fail($this->_('%s is not a float', $this)); 24 | } 25 | 26 | return $this; 27 | } 28 | 29 | public function isNearlyEqualTo($value, $epsilon = null, $failMessage = null) 30 | { 31 | if ($this->valueIsSet()->value !== $value) 32 | { 33 | // see http://www.floating-point-gui.de/errors/comparison/ for more informations 34 | $absValue = abs($value); 35 | $absCurrentValue = abs($this->value); 36 | $offset = abs($absCurrentValue - $absValue); 37 | $offsetIsNaN = is_nan($offset); 38 | 39 | if ($offsetIsNaN === false && $epsilon === null) 40 | { 41 | $epsilon = pow(10, - ini_get('precision')); 42 | } 43 | 44 | switch (true) 45 | { 46 | case $offsetIsNaN === true: 47 | case $offset / ($absCurrentValue + $absValue) >= $epsilon: 48 | case $absCurrentValue * $absValue == 0 && $offset >= pow($epsilon, 2): 49 | $this->fail(($failMessage ?: $this->_('%s is not nearly equal to %s with epsilon %s', $this, $this->getTypeOf($value), $epsilon)) . PHP_EOL . $this->diff($value)); 50 | } 51 | } 52 | 53 | return $this; 54 | } 55 | 56 | public function isZero($failMessage = null) 57 | { 58 | return $this->isEqualTo(0.0, $failMessage); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /classes/asserters/hash.php: -------------------------------------------------------------------------------- 1 | {$asserter}(); 20 | 21 | default: 22 | return parent::__get($asserter); 23 | } 24 | } 25 | 26 | public function isSha1($failMessage = null) 27 | { 28 | return $this->isHash(40, $failMessage); 29 | } 30 | 31 | public function isSha256($failMessage = null) 32 | { 33 | return $this->isHash(64, $failMessage); 34 | } 35 | 36 | public function isSha512($failMessage = null) 37 | { 38 | return $this->isHash(128, $failMessage); 39 | } 40 | 41 | public function isMd5($failMessage = null) 42 | { 43 | return $this->isHash(32, $failMessage); 44 | } 45 | 46 | protected function isHash($length, $failMessage = null) 47 | { 48 | if (strlen($this->valueIsSet()->value) === $length) 49 | { 50 | $this->matches('/^[a-fA-F0-9]+$/', $failMessage ?: $this->_('%s does not match given pattern', $this)); 51 | } 52 | else 53 | { 54 | $this->fail($failMessage ?: $this->_('%s should be a string of %d characters', $this, $length)); 55 | } 56 | 57 | return $this; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /classes/asserters/mock/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | fail($this->_('%s is not in format Y-m-d H:i:s', $this)); 29 | } 30 | } 31 | 32 | return $this; 33 | } 34 | 35 | public function getValue() 36 | { 37 | $value = parent::getValue(); 38 | 39 | return ($value instanceof \dateTime === false ? $value : $value->format(self::mysqlDateTimeFormat)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /classes/asserters/output.php: -------------------------------------------------------------------------------- 1 | setWith(null); 19 | } 20 | 21 | public function setWith($value = null, $charlist = null, $checkType = true) 22 | { 23 | if ($value instanceof \closure) 24 | { 25 | ob_start(); 26 | $value($this->getTest()); 27 | $value = ob_get_clean(); 28 | } 29 | else if ($value === null && ob_get_level() > 0) 30 | { 31 | $value = ob_get_clean(); 32 | ob_start(); 33 | } 34 | 35 | return parent::setWith($value, $charlist, $checkType); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /classes/asserters/sizeOf.php: -------------------------------------------------------------------------------- 1 | streamController = atoum\mock\stream::get($stream); 20 | 21 | return $this; 22 | } 23 | 24 | public function getStreamController() 25 | { 26 | return $this->streamController; 27 | } 28 | 29 | public function isRead($failMessage = null) 30 | { 31 | if (sizeof($this->streamIsSet()->streamController->getCalls(new test\adapter\call('stream_read'))) > 0) 32 | { 33 | $this->pass(); 34 | } 35 | else 36 | { 37 | $this->fail($failMessage ?: $this->_('stream %s is not read', $this->streamController)); 38 | } 39 | 40 | return $this; 41 | } 42 | 43 | public function isWrited($failMessage = null) 44 | { 45 | return $this->isWritten($failMessage); 46 | } 47 | 48 | public function isWritten($failMessage = null) 49 | { 50 | if (sizeof($this->streamIsSet()->streamController->getCalls(new test\adapter\call('stream_write'))) > 0) 51 | { 52 | $this->pass(); 53 | } 54 | else 55 | { 56 | $this->fail($failMessage ?: $this->_('stream %s is not written', $this->streamController)); 57 | } 58 | 59 | return $this; 60 | } 61 | 62 | protected function streamIsSet() 63 | { 64 | if ($this->streamController === null) 65 | { 66 | throw new exceptions\logic('Stream is undefined'); 67 | } 68 | 69 | return $this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /classes/asserters/testedClass.php: -------------------------------------------------------------------------------- 1 | getTestedClassName()); 22 | 23 | return parent::setWithTest($test); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /classes/cli.php: -------------------------------------------------------------------------------- 1 | adapter = $adapter ?: new atoum\adapter(); 18 | } 19 | 20 | public function isTerminal() 21 | { 22 | $isTerminal = self::$isTerminal; 23 | 24 | if ($isTerminal === null) 25 | { 26 | $isTerminal = $this->adapter->defined('STDOUT'); 27 | 28 | if ($isTerminal === true) 29 | { 30 | $stdoutStat = $this->adapter->fstat($this->adapter->constant('STDOUT')); 31 | 32 | $isTerminal = (($stdoutStat['mode'] & 0170000) === 0020000); // See for more information. 33 | 34 | if ($isTerminal === true && $this->adapter->defined('PHP_WINDOWS_VERSION_BUILD') === true) 35 | { 36 | $isTerminal = ($isTerminal && $this->adapter->getenv('ANSICON') == true); 37 | } 38 | } 39 | } 40 | 41 | return $isTerminal; 42 | } 43 | 44 | public static function forceTerminal() 45 | { 46 | self::$isTerminal = true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /classes/cli/clear.php: -------------------------------------------------------------------------------- 1 | setCli($cli); 17 | } 18 | 19 | public function setCli(atoum\cli $cli = null) 20 | { 21 | $this->cli = $cli ?: new atoum\cli(); 22 | 23 | return $this; 24 | } 25 | 26 | public function getCli() 27 | { 28 | return $this->cli; 29 | } 30 | 31 | public function decorate($string) 32 | { 33 | return ($this->cli->isTerminal() === false ? PHP_EOL : "\033[1K\r") . $string; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /classes/cli/command/exception.php: -------------------------------------------------------------------------------- 1 | setValue($value) 19 | ->setColorizer($colorizer) 20 | ; 21 | } 22 | 23 | public function __toString() 24 | { 25 | return $this->colorizer->colorize($this->value); 26 | } 27 | 28 | public function setValue($value) 29 | { 30 | $this->value = (string) $value; 31 | 32 | return $this; 33 | } 34 | 35 | public function getValue() 36 | { 37 | return $this->value; 38 | } 39 | 40 | public function setColorizer(colorizer $colorizer) 41 | { 42 | $this->colorizer = $colorizer; 43 | 44 | return $this; 45 | } 46 | 47 | public function getColorizer() 48 | { 49 | return $this->colorizer; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /classes/configurator.php: -------------------------------------------------------------------------------- 1 | script = $script; 13 | 14 | foreach ($this->script->getHelp() as $help) 15 | { 16 | list($arguments, $values) = $help; 17 | 18 | foreach ($arguments as $argument) 19 | { 20 | $this->methods[strtolower(str_replace('-', '', $argument))] = $argument; 21 | } 22 | } 23 | } 24 | 25 | public function __call($method, $arguments) 26 | { 27 | $keyMethod = strtolower($method); 28 | 29 | if (isset($this->methods[$keyMethod]) === true) 30 | { 31 | if (isset($arguments[0]) === true && is_array($arguments[0]) === true) 32 | { 33 | $arguments = $arguments[0]; 34 | } 35 | 36 | $this->script->getArgumentsParser()->invokeHandlers($this->script, $this->methods[$keyMethod], $arguments); 37 | 38 | return $this; 39 | } 40 | else 41 | { 42 | if (method_exists($this->script, $keyMethod) === false) 43 | { 44 | throw new exceptions\runtime\unexpectedValue('Method \'' . $method . '\' is unavailable'); 45 | } 46 | 47 | $return = call_user_func_array(array($this->script, $keyMethod), $arguments); 48 | 49 | return ($return === $this->script ? $this : $return); 50 | } 51 | } 52 | 53 | public function getScript() 54 | { 55 | return $this->script; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /classes/exception.php: -------------------------------------------------------------------------------- 1 | directorySeparator = $directorySeparator; 18 | 19 | return $this; 20 | } 21 | 22 | public function setAdapter(atoum\adapter $adapter = null) 23 | { 24 | $this->adapter = $adapter; 25 | 26 | return $this; 27 | } 28 | 29 | public function build($path) 30 | { 31 | return new path($path, $this->directorySeparator, $this->adapter); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /classes/includer/exception.php: -------------------------------------------------------------------------------- 1 | getInnerIterator()->current()->getBasename()) 14 | { 15 | case 'GPATH': 16 | case 'GRTAGS': 17 | case 'GTAGS': 18 | return false; 19 | 20 | default: 21 | return parent::accept(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /classes/iterators/filters/recursives/closure.php: -------------------------------------------------------------------------------- 1 | addClosure($c); 17 | } 18 | } 19 | 20 | public function addClosure(\closure $closure) 21 | { 22 | $this->closures[] = $closure; 23 | 24 | return $this; 25 | } 26 | 27 | public function getClosures() 28 | { 29 | return $this->closures; 30 | } 31 | 32 | public function accept() 33 | { 34 | foreach ($this->closures as $closure) 35 | { 36 | if ($closure($this->current(), $this->key(), $this->getInnerIterator()) === false) 37 | { 38 | return false; 39 | } 40 | } 41 | 42 | return true; 43 | } 44 | 45 | public function getChildren() 46 | { 47 | return new static( 48 | $this->getInnerIterator()->getChildren(), 49 | $this->closures 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /classes/iterators/filters/recursives/dot.php: -------------------------------------------------------------------------------- 1 | getInnerIterator()->current()->getBasename(), 0, 1) != '.'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /classes/iterators/filters/recursives/extension.php: -------------------------------------------------------------------------------- 1 | setAcceptedExtensions($acceptedExtensions); 25 | } 26 | 27 | public function setAcceptedExtensions(array $extensions) 28 | { 29 | array_walk($extensions, function(& $extension) { $extension = trim($extension, '.'); }); 30 | 31 | $this->acceptedExtensions = $extensions; 32 | 33 | return $this; 34 | } 35 | 36 | public function getAcceptedExtensions() 37 | { 38 | return $this->acceptedExtensions; 39 | } 40 | 41 | public function accept() 42 | { 43 | $path = basename((string) $this->getInnerIterator()->current()); 44 | 45 | $extension = pathinfo($path, PATHINFO_EXTENSION); 46 | 47 | return ($extension == '' || in_array($extension, $this->acceptedExtensions) === true); 48 | } 49 | 50 | public function getChildren() 51 | { 52 | return new self($this->getInnerIterator()->getChildren(), $this->acceptedExtensions); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /classes/iterators/recursives/atoum/source.php: -------------------------------------------------------------------------------- 1 | sourceDirectory = (string) $sourceDirectory; 19 | $this->pharDirectory = $pharDirectory === null ? null : (string) $pharDirectory; 20 | $this->innerIterator = new \recursiveIteratorIterator(new iterators\filters\recursives\atoum\source($this->sourceDirectory)); 21 | 22 | $this->innerIterator->rewind(); 23 | } 24 | 25 | public function getSourceDirectory() 26 | { 27 | return $this->sourceDirectory; 28 | } 29 | 30 | public function getPharDirectory() 31 | { 32 | return $this->pharDirectory; 33 | } 34 | 35 | public function getInnerIterator() 36 | { 37 | return $this->innerIterator; 38 | } 39 | 40 | public function current() 41 | { 42 | $current = $this->innerIterator->current(); 43 | 44 | return $current === null ? null : (string) $current; 45 | } 46 | 47 | public function key() 48 | { 49 | return ($this->pharDirectory === null ? $this->innerIterator->key() : preg_replace('#^(:[^:]+://)?' . preg_quote($this->sourceDirectory, '#') . '#', $this->pharDirectory, $this->innerIterator->current()) ?: null); 50 | } 51 | 52 | public function next() 53 | { 54 | return $this->innerIterator->next(); 55 | } 56 | 57 | public function rewind() 58 | { 59 | return $this->innerIterator->rewind(); 60 | } 61 | 62 | public function valid() 63 | { 64 | return $this->innerIterator->valid(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /classes/locale.php: -------------------------------------------------------------------------------- 1 | set($value); 14 | } 15 | } 16 | 17 | public function __toString() 18 | { 19 | return ($this->value === null ? 'unknown' : $this->value); 20 | } 21 | 22 | public function set($value) 23 | { 24 | $this->value = (string) $value; 25 | 26 | return $this; 27 | } 28 | 29 | public function get() 30 | { 31 | return $this->value; 32 | } 33 | 34 | public function _($string) 35 | { 36 | return static::format($string, array_slice(func_get_args(), 1)); 37 | } 38 | 39 | public function __($singular, $plural, $quantity) 40 | { 41 | return static::format($quantity <= 1 ? $singular : $plural, array_slice(func_get_args(), 3)); 42 | } 43 | 44 | private static function format($string, $arguments) 45 | { 46 | if (sizeof($arguments) > 0) 47 | { 48 | $string = vsprintf($string, $arguments); 49 | } 50 | 51 | return $string; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /classes/mailers/mail.php: -------------------------------------------------------------------------------- 1 | to === null) 17 | { 18 | throw new exceptions\runtime('To is undefined'); 19 | } 20 | 21 | if ($this->subject === null) 22 | { 23 | throw new exceptions\runtime('Subject is undefined'); 24 | } 25 | 26 | if ($this->from === null) 27 | { 28 | throw new exceptions\runtime('From is undefined'); 29 | } 30 | 31 | if ($this->replyTo === null) 32 | { 33 | throw new exceptions\runtime('Reply to is undefined'); 34 | } 35 | 36 | if ($this->xMailer === null) 37 | { 38 | throw new exceptions\runtime('X-mailer is undefined'); 39 | } 40 | 41 | $headers = 'From: ' . $this->from . self::eol . 'Reply-To: ' . $this->replyTo . self::eol . 'X-Mailer: ' . $this->xMailer; 42 | 43 | if ($this->contentType !== null) 44 | { 45 | $headers .= self::eol . 'Content-Type: ' . $this->contentType[0] . '; charset="' . $this->contentType[1] . '"'; 46 | } 47 | 48 | $this->adapter->mail($this->to, $this->subject, (string) $something, $headers); 49 | 50 | return $this; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /classes/mock/aggregator.php: -------------------------------------------------------------------------------- 1 | mock = $mock; 19 | } 20 | 21 | public function __get($property) 22 | { 23 | switch (strtolower($property)) 24 | { 25 | case 'isfluent': 26 | return $this->isFluent(); 27 | 28 | default: 29 | return parent::__get($property); 30 | } 31 | } 32 | 33 | public function setMock(mock\aggregator $mock) 34 | { 35 | $this->mock = $mock; 36 | 37 | return $this; 38 | } 39 | 40 | public function getMock() 41 | { 42 | return $this->mock; 43 | } 44 | 45 | public function isFluent() 46 | { 47 | $mock = $this->mock; 48 | 49 | return $this->setClosure(function() use ($mock) { return $mock; }); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /classes/mock/controller/iterator.php: -------------------------------------------------------------------------------- 1 | setMockController($controller); 19 | } 20 | } 21 | 22 | public function __set($keyword, $mixed) 23 | { 24 | foreach ($this->getMethods() as $method) 25 | { 26 | $this->controller->{$method}->{$keyword} = $mixed; 27 | } 28 | 29 | return $this; 30 | } 31 | 32 | public function getIterator() 33 | { 34 | return new \arrayIterator($this->getMethods()); 35 | } 36 | 37 | public function setMockController(mock\controller $controller) 38 | { 39 | $this->controller = $controller; 40 | 41 | return $this; 42 | } 43 | 44 | public function getMockController() 45 | { 46 | return $this->controller; 47 | } 48 | 49 | public function getMethods() 50 | { 51 | $methods = ($this->controller === null ? array() : $this->controller->getMethods()); 52 | 53 | foreach ($this->filters as $filter) 54 | { 55 | $methods = array_filter($methods, $filter); 56 | } 57 | 58 | return array_values(array_filter($methods, function($name) { return ($name !== '__construct'); })); 59 | } 60 | 61 | public function addFilter(\closure $filter) 62 | { 63 | $this->filters[] = $filter; 64 | 65 | return $this; 66 | } 67 | 68 | public function getFilters() 69 | { 70 | return $this->filters; 71 | } 72 | 73 | public function resetFilters() 74 | { 75 | $this->filters = array(); 76 | 77 | return $this; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /classes/mock/generator/method/exception.php: -------------------------------------------------------------------------------- 1 | name = $name; 20 | 21 | $this->isConstructor = ($name == __FUNCTION__); 22 | } 23 | 24 | public function __toString() 25 | { 26 | $string = 'public function '; 27 | 28 | if ($this->returnReference === true) 29 | { 30 | $string .= '& '; 31 | } 32 | 33 | $string .= $this->name . '(' . $this->getArgumentsAsString() . ')'; 34 | 35 | return $string; 36 | } 37 | 38 | public function getArguments() 39 | { 40 | return $this->arguments; 41 | } 42 | 43 | public function getName() 44 | { 45 | return $this->name; 46 | } 47 | 48 | public function isConstructor() 49 | { 50 | return $this->isConstructor; 51 | } 52 | 53 | public function returnReference() 54 | { 55 | if ($this->isConstructor === true) 56 | { 57 | throw new exceptions\logic('Constructor can not return a reference'); 58 | } 59 | 60 | $this->returnReference = true; 61 | 62 | return $this; 63 | } 64 | 65 | public function addArgument(method\argument $argument) 66 | { 67 | $this->arguments[] = $argument; 68 | 69 | return $this; 70 | } 71 | 72 | public function getArgumentsAsString() 73 | { 74 | $arguments = $this->arguments; 75 | 76 | array_walk($arguments, function(& $value) { $value = (string) $value; }); 77 | 78 | return join(', ', $arguments); 79 | } 80 | 81 | public static function get($name) 82 | { 83 | return new static($name); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /classes/mock/php/method/argument.php: -------------------------------------------------------------------------------- 1 | name = $name; 20 | } 21 | 22 | public function __toString() 23 | { 24 | $string = '$' . $this->name; 25 | 26 | if ($this->isReference === true) 27 | { 28 | $string = '& ' . $string; 29 | } 30 | 31 | if ($this->type !== null) 32 | { 33 | $string = $this->type . ' ' . $string; 34 | } 35 | 36 | if ($this->defaultValueIsSet === true) 37 | { 38 | $string .= '=' . var_export($this->defaultValue, true); 39 | } 40 | 41 | return $string; 42 | } 43 | 44 | public function getName() 45 | { 46 | return $this->name; 47 | } 48 | 49 | public function getVariable() 50 | { 51 | return '$' . $this->name; 52 | } 53 | 54 | public function isObject($type) 55 | { 56 | $this->type = $type; 57 | 58 | return $this; 59 | } 60 | 61 | public function isArray() 62 | { 63 | $this->type = 'array'; 64 | 65 | return $this; 66 | } 67 | 68 | public function isUntyped() 69 | { 70 | $this->type = null; 71 | 72 | return $this; 73 | } 74 | 75 | public function isReference() 76 | { 77 | $this->isReference = true; 78 | 79 | return $this; 80 | } 81 | 82 | public function setDefaultValue($defaultValue) 83 | { 84 | $this->defaultValue = $defaultValue; 85 | $this->defaultValueIsSet = true; 86 | 87 | return $this; 88 | } 89 | 90 | public static function get($name) 91 | { 92 | return new static($name); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /classes/mock/stream/invoker.php: -------------------------------------------------------------------------------- 1 | methodName = strtolower($methodName); 16 | } 17 | 18 | public function getMethodName() 19 | { 20 | return $this->methodName; 21 | } 22 | 23 | public function offsetSet($call, $mixed) 24 | { 25 | if ($this->methodName == 'dir_readdir' && $mixed instanceof \mageekguy\atoum\mock\stream\controller) 26 | { 27 | $mixed = $mixed->getBasename(); 28 | } 29 | 30 | return parent::offsetSet($call, $mixed); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /classes/mock/streams/fs/controller/factory.php: -------------------------------------------------------------------------------- 1 | setPermissions('755'); 17 | } 18 | 19 | public function setPermissions($permissions) 20 | { 21 | return parent::setPermissions(0400000 | octdec($permissions)); 22 | } 23 | 24 | public function getContents() 25 | { 26 | return array(); 27 | } 28 | 29 | public function mkdir($path, $mode, $options) 30 | { 31 | if ($this->exists === true) 32 | { 33 | return false; 34 | } 35 | else 36 | { 37 | $this->setPermissions($mode)->exists = true; 38 | 39 | return true; 40 | } 41 | } 42 | 43 | public function rmdir($path, $options) 44 | { 45 | if ($this->exists === false || $this->checkIfWritable() === false) 46 | { 47 | return false; 48 | } 49 | else 50 | { 51 | $this->exists = false; 52 | 53 | return true; 54 | } 55 | } 56 | 57 | public function dir_opendir($path, $useSafeMode) 58 | { 59 | return $this->exists; 60 | } 61 | 62 | public function dir_closedir() 63 | { 64 | return $this->exists; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /classes/mock/streams/fs/file.php: -------------------------------------------------------------------------------- 1 | adapter->defined('PHP_BINARY') === true) 17 | { 18 | $phpPath = $this->adapter->constant('PHP_BINARY'); 19 | } 20 | 21 | if ($phpPath === null) 22 | { 23 | $phpPath = $this->adapter->getenv('PHP_PEAR_PHP_BIN'); 24 | 25 | if ($phpPath === false) 26 | { 27 | $phpPath = $this->adapter->getenv('PHPBIN'); 28 | 29 | if ($phpPath === false) 30 | { 31 | $phpDirectory = $this->adapter->constant('PHP_BINDIR'); 32 | 33 | if ($phpDirectory === null) 34 | { 35 | throw new exceptions\runtime('Unable to find PHP executable'); 36 | } 37 | 38 | $phpPath = $phpDirectory . '/php'; 39 | } 40 | } 41 | } 42 | } 43 | 44 | return parent::setBinaryPath($phpPath); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /classes/php/exception.php: -------------------------------------------------------------------------------- 1 | parent !== null) 16 | { 17 | throw new exceptions\runtime('Parent is already set'); 18 | } 19 | 20 | $parent->append($this); 21 | 22 | return $this; 23 | } 24 | 25 | public function getParent() 26 | { 27 | return $this->parent; 28 | } 29 | 30 | public function getRoot() 31 | { 32 | $root = null; 33 | 34 | $parent = $this->getParent(); 35 | 36 | while ($parent !== null) 37 | { 38 | $root = $parent; 39 | 40 | $parent = $parent->getParent(); 41 | } 42 | 43 | return $root; 44 | } 45 | 46 | public abstract function __toString(); 47 | public abstract function prev(); 48 | public abstract function end(); 49 | public abstract function append(value $value); 50 | public abstract function getValue(); 51 | public abstract function seek($key); 52 | } 53 | -------------------------------------------------------------------------------- /classes/php/tokenizer/iterators/phpArgument.php: -------------------------------------------------------------------------------- 1 | defaultValue; 18 | } 19 | 20 | public function appendDefaultValue(iterators\phpDefaultValue $phpDefaultValue) 21 | { 22 | $this->defaultValue = $phpDefaultValue; 23 | 24 | return $this->append($phpDefaultValue); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /classes/php/tokenizer/iterators/phpConstant.php: -------------------------------------------------------------------------------- 1 | findTag(T_FUNCTION); 20 | 21 | if ($key !== null) 22 | { 23 | $this->goToNextTagWhichIsNot(array(T_WHITESPACE, T_COMMENT)); 24 | 25 | $token = $this->current(); 26 | 27 | if ($token !== null && $token->getTag() === T_STRING) 28 | { 29 | $name = $token->getValue(); 30 | } 31 | } 32 | 33 | return $name; 34 | } 35 | 36 | public function reset() 37 | { 38 | $this->arguments = array(); 39 | 40 | return parent::reset(); 41 | } 42 | 43 | public function appendArgument(iterators\phpArgument $phpArgument) 44 | { 45 | $this->arguments[] = $phpArgument; 46 | 47 | return $this->append($phpArgument); 48 | } 49 | 50 | public function getArguments() 51 | { 52 | return $this->arguments; 53 | } 54 | 55 | public function getArgument($index) 56 | { 57 | return (isset($this->arguments[$index]) === false ? null : $this->arguments[$index]); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /classes/php/tokenizer/iterators/phpImportation.php: -------------------------------------------------------------------------------- 1 | namespaces = array(); 19 | 20 | return parent::reset(); 21 | } 22 | 23 | public function appendNamespace(iterators\phpNamespace $phpNamespace) 24 | { 25 | $this->namespaces[] = $phpNamespace; 26 | 27 | return $this->append($phpNamespace); 28 | } 29 | 30 | public function getNamespaces() 31 | { 32 | return $this->namespaces; 33 | } 34 | 35 | public function getNamespace($index) 36 | { 37 | return (isset($this->namespaces[$index]) === false ? null : $this->namespaces[$index]); 38 | } 39 | 40 | public function appendImportation(iterators\phpImportation $phpImportation) 41 | { 42 | $this->importations[] = $phpImportation; 43 | 44 | return $this->append($phpImportation); 45 | } 46 | 47 | public function getImportations() 48 | { 49 | return $this->importations; 50 | } 51 | 52 | public function getImportation($index) 53 | { 54 | return (isset($this->importations[$index]) === false ? null : $this->importations[$index]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /classes/reader.php: -------------------------------------------------------------------------------- 1 | setAdapter($adapter); 12 | } 13 | 14 | public function setAdapter(adapter $adapter = null) 15 | { 16 | $this->adapter = $adapter ?: new adapter(); 17 | 18 | return $this; 19 | } 20 | 21 | public function getAdapter() 22 | { 23 | return $this->adapter; 24 | } 25 | 26 | public abstract function read($length = null); 27 | } 28 | -------------------------------------------------------------------------------- /classes/readers/std/in.php: -------------------------------------------------------------------------------- 1 | init(); 17 | 18 | // fgets() must be called without any second argument if $length is null to avoid message "Warning: fgets(): Length parameter must be greater than 0" 19 | return ($length === null ? $this->adapter->fgets($this->resource) : $this->adapter->fgets($this->resource, $length)); 20 | } 21 | 22 | protected function init() 23 | { 24 | if ($this->resource === null) 25 | { 26 | $resource = $this->adapter->fopen('php://stdin', 'r'); 27 | 28 | if ($resource === false) 29 | { 30 | throw new exceptions\runtime('Unable to open php://stdin stream'); 31 | } 32 | 33 | $this->resource = $resource; 34 | } 35 | 36 | return $this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/field.php: -------------------------------------------------------------------------------- 1 | events = $events; 17 | 18 | $this->setLocale(); 19 | } 20 | 21 | public function setLocale(atoum\locale $locale = null) 22 | { 23 | $this->locale = $locale ?: new atoum\locale(); 24 | 25 | return $this; 26 | } 27 | 28 | public function getLocale() 29 | { 30 | return $this->locale; 31 | } 32 | 33 | public function getEvents() 34 | { 35 | return $this->events; 36 | } 37 | 38 | public function canHandleEvent($event) 39 | { 40 | return ($this->events === null ? true : in_array($event, $this->events)); 41 | } 42 | 43 | public function handleEvent($event, atoum\observable $observable) 44 | { 45 | return $this->canHandleEvent($event); 46 | } 47 | 48 | abstract public function __toString(); 49 | } 50 | -------------------------------------------------------------------------------- /classes/report/fields/event.php: -------------------------------------------------------------------------------- 1 | observable; 21 | } 22 | 23 | public function getEvent() 24 | { 25 | return $this->event; 26 | } 27 | 28 | public function handleEvent($event, atoum\observable $observable) 29 | { 30 | if (parent::handleEvent($event, $observable) === false) 31 | { 32 | $this->observable = null; 33 | $this->event = null; 34 | 35 | return false; 36 | } 37 | else 38 | { 39 | $this->observable = $observable; 40 | $this->event = $event; 41 | 42 | return true; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/report/fields/runner.php: -------------------------------------------------------------------------------- 1 | author; 26 | } 27 | 28 | public function getVersion() 29 | { 30 | return $this->version; 31 | } 32 | 33 | public function getPath() 34 | { 35 | return $this->path; 36 | } 37 | 38 | public function handleEvent($event, \mageekguy\atoum\observable $observable) 39 | { 40 | if (parent::handleEvent($event, $observable) === false) 41 | { 42 | return false; 43 | } 44 | else 45 | { 46 | $this->author = \mageekguy\atoum\author; 47 | $this->path = $observable->getScore()->getAtoumPath(); 48 | $this->version = $observable->getScore()->getAtoumVersion(); 49 | 50 | return true; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /classes/report/fields/runner/atoum/cli.php: -------------------------------------------------------------------------------- 1 | setPrompt() 23 | ->setColorizer() 24 | ; 25 | } 26 | 27 | public function __toString() 28 | { 29 | return ($this->author === null || $this->version === null ? '' : $this->prompt . $this->colorizer->colorize(sprintf($this->locale->_('atoum version %s by %s (%s)'), $this->version, $this->author, $this->path)) . PHP_EOL); 30 | } 31 | 32 | public function setPrompt(prompt $prompt = null) 33 | { 34 | $this->prompt = $prompt ?: new prompt; 35 | 36 | return $this; 37 | } 38 | 39 | public function getPrompt() 40 | { 41 | return $this->prompt; 42 | } 43 | 44 | public function setColorizer(colorizer $colorizer = null) 45 | { 46 | $this->colorizer = $colorizer ?: new colorizer(); 47 | 48 | return $this; 49 | } 50 | 51 | public function getColorizer() 52 | { 53 | return $this->colorizer; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /classes/report/fields/runner/atoum/phing.php: -------------------------------------------------------------------------------- 1 | author === null || $this->version === null ? '' : $this->prompt . $this->colorizer->colorize(sprintf($this->locale->_("Atoum version: %s \nAtoum path: %s \nAtoum author: %s"), $this->version, $this->path, $this->author))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /classes/report/fields/runner/duration.php: -------------------------------------------------------------------------------- 1 | value; 24 | } 25 | 26 | public function handleEvent($event, observable $observable) 27 | { 28 | if (parent::handleEvent($event, $observable) === false) 29 | { 30 | return false; 31 | } 32 | else 33 | { 34 | $this->value = $observable->getRunningDuration(); 35 | 36 | return true; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /classes/report/fields/runner/duration/phing.php: -------------------------------------------------------------------------------- 1 | prompt . 19 | sprintf( 20 | $this->locale->_('%1$s: %2$s.'), 21 | $this->titleColorizer->colorize($this->locale->_('Running duration')), 22 | $this->durationColorizer->colorize($this->value === null ? $this->locale->_('unknown') : sprintf($this->locale->__('%4.2f second', '%4.2f seconds', $this->value), $this->value) 23 | ) 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /classes/report/fields/runner/errors.php: -------------------------------------------------------------------------------- 1 | runner; 24 | } 25 | 26 | public function handleEvent($event, observable $observable) 27 | { 28 | if (parent::handleEvent($event, $observable) === false) 29 | { 30 | return false; 31 | } 32 | else 33 | { 34 | $this->runner = $observable; 35 | 36 | return true; 37 | } 38 | } 39 | 40 | public static function getType($error) 41 | { 42 | switch ($error) 43 | { 44 | case E_ERROR: 45 | return 'E_ERROR'; 46 | 47 | case E_WARNING: 48 | return 'E_WARNING'; 49 | 50 | case E_NOTICE: 51 | return 'E_NOTICE'; 52 | 53 | case E_USER_NOTICE: 54 | return 'E_USER_NOTICE'; 55 | 56 | case E_USER_WARNING: 57 | return 'E_USER_WARNING'; 58 | 59 | case E_USER_ERROR: 60 | return 'E_USER_ERROR'; 61 | 62 | case E_RECOVERABLE_ERROR: 63 | return 'E_RECOVERABLE_ERROR'; 64 | 65 | case E_DEPRECATED: 66 | return 'E_DEPRECATED'; 67 | 68 | case E_USER_DEPRECATED: 69 | return 'E_USER_DEPRECATED'; 70 | 71 | default: 72 | return strtoupper($error); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /classes/report/fields/runner/event.php: -------------------------------------------------------------------------------- 1 | runner; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->runner = $observable; 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures.php: -------------------------------------------------------------------------------- 1 | runner; 24 | } 25 | 26 | public function handleEvent($event, observable $observable) 27 | { 28 | if (parent::handleEvent($event, $observable) === false) 29 | { 30 | return false; 31 | } 32 | else 33 | { 34 | $this->runner = $observable; 35 | 36 | return true; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures/execute.php: -------------------------------------------------------------------------------- 1 | setCommand($command) 24 | ->setAdapter() 25 | ; 26 | } 27 | 28 | public function __toString() 29 | { 30 | if ($this->runner !== null) 31 | { 32 | $fails = array(); 33 | 34 | foreach ($this->runner->getScore()->getFailAssertions() as $fail) 35 | { 36 | switch (true) 37 | { 38 | case isset($fails[$fail['file']]) === false: 39 | case $fails[$fail['file']] > $fail['line']: 40 | $fails[$fail['file']] = $fail['line']; 41 | } 42 | } 43 | 44 | ksort($fails); 45 | 46 | foreach ($fails as $file => $line) 47 | { 48 | $this->adapter->system(sprintf($this->getCommand(), $file, $line)); 49 | } 50 | } 51 | 52 | return ''; 53 | } 54 | 55 | public function setCommand($command) 56 | { 57 | $this->command = (string) $command; 58 | 59 | return $this; 60 | } 61 | 62 | public function getCommand() 63 | { 64 | return $this->command; 65 | } 66 | 67 | public function setAdapter(adapter $adapter = null) 68 | { 69 | $this->adapter = $adapter ?: new adapter(); 70 | 71 | return $this; 72 | } 73 | 74 | public function getAdapter() 75 | { 76 | return $this->adapter; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures/execute/macos/macvim.php: -------------------------------------------------------------------------------- 1 | /dev/null &'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures/execute/unix/gedit.php: -------------------------------------------------------------------------------- 1 | /dev/null &'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures/execute/unix/gvim.php: -------------------------------------------------------------------------------- 1 | /dev/null &'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /classes/report/fields/runner/failures/execute/unix/phpstorm.php: -------------------------------------------------------------------------------- 1 | /dev/null &'; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /classes/report/fields/runner/outputs.php: -------------------------------------------------------------------------------- 1 | runner; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->runner = $observable; 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/php/path.php: -------------------------------------------------------------------------------- 1 | path; 23 | } 24 | 25 | public function handleEvent($event, atoum\observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->path = $observable->getScore()->getPhpPath(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/php/path/cli.php: -------------------------------------------------------------------------------- 1 | setPrompt() 25 | ->setTitleColorizer() 26 | ->setPathColorizer() 27 | ; 28 | } 29 | 30 | public function __toString() 31 | { 32 | return 33 | $this->prompt . 34 | sprintf( 35 | $this->locale->_('%1$s: %2$s'), 36 | $this->titleColorizer->colorize($this->locale->_('PHP path')), 37 | $this->pathColorizer->colorize($this->path) 38 | ) . 39 | PHP_EOL 40 | ; 41 | } 42 | 43 | public function setPrompt(prompt $prompt = null) 44 | { 45 | $this->prompt = $prompt ?: new prompt(); 46 | 47 | return $this; 48 | } 49 | 50 | public function getPrompt() 51 | { 52 | return $this->prompt; 53 | } 54 | 55 | public function setTitleColorizer(colorizer $colorizer = null) 56 | { 57 | $this->titleColorizer = $colorizer ?: new colorizer(); 58 | 59 | return $this; 60 | } 61 | 62 | public function getTitleColorizer() 63 | { 64 | return $this->titleColorizer; 65 | } 66 | 67 | public function setPathColorizer(colorizer $colorizer = null) 68 | { 69 | $this->pathColorizer = $colorizer ?: new colorizer(); 70 | 71 | return $this; 72 | } 73 | 74 | public function getPathColorizer() 75 | { 76 | return $this->pathColorizer; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /classes/report/fields/runner/php/version.php: -------------------------------------------------------------------------------- 1 | version; 23 | } 24 | 25 | public function handleEvent($event, atoum\observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->version = $observable->getScore()->getPhpVersion(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/result/notifier/image.php: -------------------------------------------------------------------------------- 1 | getMessage() . PHP_EOL; 26 | } 27 | } 28 | 29 | public function setSuccessImage($path) 30 | { 31 | $this->successImage = $path; 32 | 33 | return $this; 34 | } 35 | 36 | public function getSuccessImage() 37 | { 38 | return $this->successImage; 39 | } 40 | 41 | public function setFailureImage($path) 42 | { 43 | $this->failureImage = $path; 44 | 45 | return $this; 46 | } 47 | 48 | public function getFailureImage() 49 | { 50 | return $this->failureImage; 51 | } 52 | 53 | public function getImage($success) 54 | { 55 | $image = $success ? $this->getSuccessImage() : $this->getFailureImage(); 56 | 57 | if ($this->getAdapter()->file_exists($image) === false) 58 | { 59 | throw new exceptions\runtime(sprintf('File %s does not exist', $image)); 60 | } 61 | 62 | return $image; 63 | } 64 | 65 | public function send($title, $message, $success) 66 | { 67 | return parent::send($title, $message, $this->getImage($success)); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /classes/report/fields/runner/result/notifier/image/growl.php: -------------------------------------------------------------------------------- 1 | callbackUrl = $url; 23 | 24 | return $this; 25 | } 26 | 27 | public function send($title, $message, $success) 28 | { 29 | return $this->adapter->system(sprintf($this->getCommand(), escapeshellarg($title), escapeshellarg($message), escapeshellarg($this->getImage($success)), escapeshellarg($this->callbackUrl))); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /classes/report/fields/runner/result/notifier/image/libnotify.php: -------------------------------------------------------------------------------- 1 | callbackCommand = $command; 22 | 23 | return $this; 24 | } 25 | 26 | public function send($title, $message, $success) 27 | { 28 | return $this->adapter->system(sprintf($this->getCommand(), escapeshellarg($title), escapeshellarg($message), escapeshellarg($this->callbackCommand))); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tap/plan.php: -------------------------------------------------------------------------------- 1 | testMethodNumber <= 0 ? '' : '1..' . $this->testMethodNumber . PHP_EOL); 22 | } 23 | 24 | public function handleEvent($event, \mageekguy\atoum\observable $observable) 25 | { 26 | if (parent::handleEvent($event, $observable) === false) 27 | { 28 | return false; 29 | } 30 | else 31 | { 32 | $this->testMethodNumber = $observable->getTestMethodNumber(); 33 | 34 | return true; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/coverage.php: -------------------------------------------------------------------------------- 1 | coverage; 23 | } 24 | 25 | public function handleEvent($event, atoum\observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->coverage = $observable->getScore()->getCoverage(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/duration.php: -------------------------------------------------------------------------------- 1 | value; 24 | } 25 | 26 | public function getTestNumber() 27 | { 28 | return $this->testNumber; 29 | } 30 | 31 | public function handleEvent($event, atoum\observable $observable) 32 | { 33 | if (parent::handleEvent($event, $observable) === false) 34 | { 35 | return false; 36 | } 37 | else 38 | { 39 | $this->value = $observable->getScore()->getTotalDuration(); 40 | $this->testNumber = $observable->getTestNumber(); 41 | 42 | return true; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/memory.php: -------------------------------------------------------------------------------- 1 | value; 24 | } 25 | 26 | public function getTestNumber() 27 | { 28 | return $this->testNumber; 29 | } 30 | 31 | public function handleEvent($event, atoum\observable $observable) 32 | { 33 | if (parent::handleEvent($event, $observable) === false) 34 | { 35 | return false; 36 | } 37 | else 38 | { 39 | $this->value = $observable->getScore()->getTotalMemoryUsage(); 40 | $this->testNumber = $observable->getTestNumber(); 41 | 42 | return true; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/memory/phing.php: -------------------------------------------------------------------------------- 1 | locale->__('Total test memory usage', 'Total tests memory usage', $this->testNumber); 18 | $memory = ($this->value === null ? $this->locale->_('unknown') : sprintf($this->locale->_('%4.2f Mb'), $this->value / 1048576)); 19 | 20 | return $this->prompt . sprintf($this->locale->_('%s: %s.'), $this->titleColorizer->colorize($title), $this->memoryColorizer->colorize($memory)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/skipped.php: -------------------------------------------------------------------------------- 1 | runner; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->runner = $observable; 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/uncompleted.php: -------------------------------------------------------------------------------- 1 | runner; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->runner = $observable; 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/runner/tests/void.php: -------------------------------------------------------------------------------- 1 | runner; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->runner = $observable; 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/test/duration.php: -------------------------------------------------------------------------------- 1 | value; 23 | } 24 | 25 | public function handleEvent($event, observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->value = $observable->getScore()->getTotalDuration(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/test/duration/phing.php: -------------------------------------------------------------------------------- 1 | prompt . 18 | sprintf( 19 | $this->locale->_('%1$s'), 20 | $this->durationColorizer->colorize($this->value === null ? $this->locale->_('unknown') : sprintf($this->locale->__('%4.2f s', '%4.2f s', $this->value), $this->value)) 21 | ) 22 | ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /classes/report/fields/test/event.php: -------------------------------------------------------------------------------- 1 | event) 16 | { 17 | case atoum\test::runStart: 18 | return '['; 19 | 20 | case atoum\test::runStop: 21 | return '] '; 22 | 23 | case atoum\test::success: 24 | return 'S'; 25 | 26 | case atoum\test::void: 27 | return '0'; 28 | 29 | case atoum\test::uncompleted: 30 | return 'U'; 31 | 32 | case atoum\test::fail: 33 | return 'F'; 34 | 35 | case atoum\test::error: 36 | return 'e'; 37 | 38 | case atoum\test::exception: 39 | return 'E'; 40 | 41 | default: 42 | return ''; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/report/fields/test/memory.php: -------------------------------------------------------------------------------- 1 | value; 23 | } 24 | 25 | public function handleEvent($event, atoum\observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->value = $observable->getScore()->getTotalMemoryUsage(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/test/memory/phing.php: -------------------------------------------------------------------------------- 1 | prompt . 18 | sprintf( 19 | $this->locale->_('%1$s'), 20 | $this->memoryColorizer->colorize($this->value === null ? $this->locale->_('unknown') : sprintf($this->locale->_('%4.2f Mb'), $this->value / 1048576)) 21 | ) 22 | ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /classes/report/fields/test/run.php: -------------------------------------------------------------------------------- 1 | testClass; 23 | } 24 | 25 | public function handleEvent($event, atoum\observable $observable) 26 | { 27 | if (parent::handleEvent($event, $observable) === false) 28 | { 29 | return false; 30 | } 31 | else 32 | { 33 | $this->testClass = $observable->getClass(); 34 | 35 | return true; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /classes/report/fields/test/run/cli.php: -------------------------------------------------------------------------------- 1 | setPrompt() 24 | ->setColorizer() 25 | ; 26 | } 27 | 28 | public function __toString() 29 | { 30 | return $this->prompt . 31 | ( 32 | $this->testClass === null 33 | ? 34 | $this->colorizer->colorize($this->locale->_('There is currently no test running.')) 35 | : 36 | sprintf($this->locale->_('%s...'), $this->colorizer->colorize($this->testClass)) 37 | ) . 38 | PHP_EOL 39 | ; 40 | } 41 | 42 | public function setPrompt(prompt $prompt = null) 43 | { 44 | $this->prompt = $prompt ?: new prompt(); 45 | 46 | return $this; 47 | } 48 | 49 | public function getPrompt() 50 | { 51 | return $this->prompt; 52 | } 53 | 54 | public function setColorizer(colorizer $colorizer = null) 55 | { 56 | $this->colorizer = $colorizer ?: new colorizer(); 57 | 58 | return $this; 59 | } 60 | 61 | public function getColorizer() 62 | { 63 | return $this->colorizer; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /classes/report/fields/test/run/phing.php: -------------------------------------------------------------------------------- 1 | prompt . ($this->testClass === null ? $this->colorizer->colorize($this->locale->_('There is currently no test running.')) : sprintf($this->locale->_('%s : '), $this->colorizer->colorize($this->testClass))); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /classes/report/writers/asynchronous.php: -------------------------------------------------------------------------------- 1 | string; 18 | } 19 | 20 | public function handleEvent($event, atoum\observable $observable) 21 | { 22 | switch ($event) 23 | { 24 | case atoum\test::fail: 25 | case atoum\test::error: 26 | case atoum\test::exception: 27 | case atoum\test::uncompleted: 28 | $this->fail = true; 29 | break; 30 | } 31 | 32 | parent::handleEvent($event, $observable)->build($event); 33 | 34 | if ($event === atoum\runner::runStop) 35 | { 36 | if ($this->title !== null) 37 | { 38 | $this->title = sprintf($this->title, $this->adapter->date($this->locale->_('Y-m-d')), $this->adapter->date($this->locale->_('H:i:s')), $this->fail === true ? $this->locale->_('FAIL') : $this->locale->_('SUCCESS')); 39 | } 40 | 41 | foreach ($this->writers as $writer) 42 | { 43 | $writer->writeAsynchronousReport($this)->reset(); 44 | } 45 | } 46 | 47 | return $this; 48 | } 49 | 50 | public function addWriter(report\writers\asynchronous $writer) 51 | { 52 | return $this->doAddWriter($writer); 53 | } 54 | 55 | protected function build($event) 56 | { 57 | foreach ($this->lastSetFields as $field) 58 | { 59 | $this->string .= (string) $field; 60 | } 61 | 62 | return $this; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /classes/reports/realtime.php: -------------------------------------------------------------------------------- 1 | write($event); 15 | 16 | if ($event === atoum\runner::runStop) 17 | { 18 | foreach ($this->writers as $writer) 19 | { 20 | $writer->reset(); 21 | } 22 | } 23 | 24 | return $this; 25 | } 26 | 27 | public function addWriter(report\writers\realtime $writer) 28 | { 29 | return $this->doAddWriter($writer); 30 | } 31 | 32 | public function isOverridableBy(report $report) 33 | { 34 | return ($report instanceof self) === false; 35 | } 36 | 37 | protected function write($event) 38 | { 39 | foreach ($this->writers as $writer) 40 | { 41 | $writer->writeRealtimeReport($this, $event); 42 | } 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /classes/reports/realtime/tap.php: -------------------------------------------------------------------------------- 1 | addField(new fields\runner\tap\plan()) 18 | ->addField(new fields\test\event\tap()) 19 | ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /classes/script/prompt.php: -------------------------------------------------------------------------------- 1 | setInputReader() 21 | ->setOutputWriter() 22 | ; 23 | } 24 | 25 | public function getInputReader() 26 | { 27 | return $this->inputReader; 28 | } 29 | 30 | public function setInputReader(reader $inputReader = null) 31 | { 32 | $this->inputReader = $inputReader ?: new std\in(); 33 | 34 | return $this; 35 | } 36 | 37 | public function getOutputWriter() 38 | { 39 | return $this->outputWriter; 40 | } 41 | 42 | public function setOutputWriter(writer $writer = null) 43 | { 44 | $this->outputWriter = $writer ?: new writers\std\out(); 45 | 46 | return $this; 47 | } 48 | 49 | public function ask($message) 50 | { 51 | $this->outputWriter->write($message); 52 | 53 | return $this->inputReader->read(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /classes/scripts/treemap/analyzer.php: -------------------------------------------------------------------------------- 1 | setCallback($callback) 19 | ->setMetricName($metricName) 20 | ->setMetricLabel($metricLabel) 21 | ; 22 | } 23 | 24 | public function setCallback(\closure $callback = null) 25 | { 26 | $this->callback = $callback ?: function() { return 0; }; 27 | 28 | return $this; 29 | } 30 | 31 | public function getCallback() 32 | { 33 | return $this->callback; 34 | } 35 | 36 | public function setMetricName($metricName) 37 | { 38 | $this->metricName = (string) $metricName; 39 | 40 | return $this->setMetricLabel(ucfirst($this->metricName)); 41 | } 42 | 43 | public function getMetricName() 44 | { 45 | return $this->metricName; 46 | } 47 | 48 | public function setMetricLabel($metricLabel = null) 49 | { 50 | $this->metricLabel = ($metricLabel ? (string) $metricLabel : ucfirst($this->metricName)); 51 | 52 | return $this; 53 | } 54 | 55 | public function getMetricLabel() 56 | { 57 | return $this->metricLabel; 58 | } 59 | 60 | public function getMetricFromFile(\splFileInfo $file) 61 | { 62 | return call_user_func_array($this->callback, array($file)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /classes/scripts/treemap/analyzers/size.php: -------------------------------------------------------------------------------- 1 | getSize(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /classes/scripts/treemap/analyzers/sloc.php: -------------------------------------------------------------------------------- 1 | openFile() as $line) 27 | { 28 | if (preg_match('/^\s+$/', $line)) 29 | { 30 | $blankLines++; 31 | } 32 | else 33 | { 34 | $codeLines++; 35 | } 36 | } 37 | 38 | $totalLines = $codeLines + $blankLines; 39 | 40 | return $totalLines === 0 ? 0 : ($blankLines / $totalLines <= 0.25 ? $totalLines : $codeLines); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /classes/scripts/treemap/analyzers/token.php: -------------------------------------------------------------------------------- 1 | name = $name; 19 | 20 | $this->setCallback(); 21 | } 22 | 23 | public function getName() 24 | { 25 | return $this->name; 26 | } 27 | 28 | public function setCallback(\closure $callback = null) 29 | { 30 | $this->callback = $callback ?: function() { return false; }; 31 | 32 | return $this; 33 | } 34 | 35 | public function getCallback() 36 | { 37 | return $this->callback; 38 | } 39 | 40 | public function setMinDepthColor($color) 41 | { 42 | $this->minDepthColor = static::checkColor($color); 43 | 44 | return $this; 45 | } 46 | 47 | public function getMinDepthColor() 48 | { 49 | return $this->minDepthColor; 50 | } 51 | 52 | public function setMaxDepthColor($color) 53 | { 54 | $this->maxDepthColor = static::checkColor($color); 55 | 56 | return $this; 57 | } 58 | 59 | public function getMaxDepthColor() 60 | { 61 | return $this->maxDepthColor; 62 | } 63 | 64 | public function categorize(\splFileInfo $file) 65 | { 66 | return call_user_func_array($this->callback, array($file)); 67 | } 68 | 69 | protected static function checkColor($color) 70 | { 71 | if (preg_match('/^#?[a-f0-9]{6}$/i', $color) === 0) 72 | { 73 | throw new exceptions\logic\invalidArgument('Color must be in hexadecimal format'); 74 | } 75 | 76 | return '#' . ltrim($color, '#'); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /classes/superglobals.php: -------------------------------------------------------------------------------- 1 | check($superglobal)->superglobals[$superglobal] = $value; 16 | } 17 | 18 | public function & __get($superglobal) 19 | { 20 | $this->check($superglobal); 21 | 22 | if (array_key_exists($superglobal, $this->superglobals) === true) 23 | { 24 | return $this->superglobals[$superglobal]; 25 | } 26 | else switch ($superglobal) 27 | { 28 | case 'GLOBALS': 29 | return $GLOBALS; 30 | 31 | case '_SERVER': 32 | return $_SERVER; 33 | 34 | case '_GET': 35 | return $_GET; 36 | 37 | case '_POST': 38 | return $_POST; 39 | 40 | case '_FILES': 41 | return $_FILES; 42 | 43 | case '_COOKIE': 44 | return $_COOKIE; 45 | 46 | case '_SESSION': 47 | return $_SESSION; 48 | 49 | case '_REQUEST': 50 | return $_REQUEST; 51 | 52 | case '_ENV': 53 | return $_ENV; 54 | } 55 | } 56 | 57 | protected function check($superglobal) 58 | { 59 | switch ($superglobal) 60 | { 61 | case 'GLOBALS': 62 | case '_SERVER': 63 | case '_GET': 64 | case '_POST': 65 | case '_FILES': 66 | case '_COOKIE': 67 | case '_SESSION': 68 | case '_REQUEST': 69 | case '_ENV': 70 | return $this; 71 | 72 | default: 73 | throw new exceptions\logic\invalidArgument('PHP superglobal \'$' . $superglobal . '\' does not exist'); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /classes/template/parser/exception.php: -------------------------------------------------------------------------------- 1 | errorLine = $errorLine; 19 | $this->errorOffset = $errorOffset; 20 | } 21 | 22 | public function getErrorLine() 23 | { 24 | return $this->errorLine; 25 | } 26 | 27 | public function getErrorOffset() 28 | { 29 | return $this->errorOffset; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /classes/test/adapter/call/arguments/decorator.php: -------------------------------------------------------------------------------- 1 | 0) 12 | { 13 | $string = array(); 14 | 15 | foreach ($arguments as $argument) 16 | { 17 | switch ($type = gettype($argument)) 18 | { 19 | case 'boolean': 20 | $string[] = ($argument ? 'TRUE' : 'FALSE'); 21 | break; 22 | 23 | case 'integer': 24 | $string[] = 'integer(' . $argument . ')'; 25 | break; 26 | 27 | case 'double': 28 | $string[] = 'float(' . $argument . ')'; 29 | break; 30 | 31 | case 'string': 32 | $string[] = 'string(' . strlen($argument) . ') "' . $argument . '"'; 33 | break; 34 | 35 | case 'array': 36 | $string[] = 'array(' . ($size = sizeof($argument)) . ') {' . ($size <= 0 ? '' : '...') . '}'; 37 | break; 38 | 39 | case 'object': 40 | $string[] = 'object(' . get_class($argument) . ')'; 41 | break; 42 | 43 | case 'resource': 44 | ob_start(); 45 | var_dump($argument); 46 | $string[] = ob_get_clean(); 47 | break; 48 | 49 | case 'NULL': 50 | $string[] = $type; 51 | break; 52 | 53 | default: 54 | $string[] = $type; 55 | } 56 | } 57 | 58 | $string = join(', ', $string); 59 | } 60 | 61 | return $string; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /classes/test/adapter/call/decorator.php: -------------------------------------------------------------------------------- 1 | setArgumentsDecorator(); 17 | } 18 | 19 | public function getArgumentsDecorator() 20 | { 21 | return $this->argumentsDecorator; 22 | } 23 | 24 | public function setArgumentsDecorator(arguments\decorator $decorator = null) 25 | { 26 | $this->argumentsDecorator = $decorator ?: new arguments\decorator(); 27 | 28 | return $this; 29 | } 30 | 31 | public function decorate(call $call) 32 | { 33 | $string = ''; 34 | 35 | $function = $call->getFunction(); 36 | 37 | if ($function !== null) 38 | { 39 | $string = $function . '('; 40 | 41 | $arguments = $call->getArguments(); 42 | 43 | if ($arguments === null) 44 | { 45 | $string .= '*'; 46 | } 47 | else 48 | { 49 | $string .= $this->argumentsDecorator->decorate($call->getArguments()); 50 | } 51 | 52 | $string .= ')'; 53 | } 54 | 55 | return $string; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /classes/test/adapter/call/decorators/addClass.php: -------------------------------------------------------------------------------- 1 | class = (is_object($mixed) === false ? (string) $mixed : get_class($mixed)); 18 | } 19 | 20 | public function getClass() 21 | { 22 | return $this->class; 23 | } 24 | 25 | public function decorate(call $call) 26 | { 27 | $string = parent::decorate($call); 28 | 29 | if ($string !== '') 30 | { 31 | $string = $this->class . '::' . $string; 32 | } 33 | 34 | return $string; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /classes/test/adapter/calls/decorator.php: -------------------------------------------------------------------------------- 1 | 0) 18 | { 19 | $format = '[%' . strlen((string) $sizeOfCalls) . 's] %s'; 20 | 21 | $position = 1; 22 | 23 | foreach ($calls->getTimeline() as $call) 24 | { 25 | $string .= sprintf($format, $position++, $call) . PHP_EOL; 26 | } 27 | } 28 | 29 | return $string; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /classes/test/adapter/storage.php: -------------------------------------------------------------------------------- 1 | reset(); 16 | } 17 | 18 | public function count() 19 | { 20 | return sizeof($this->adapters); 21 | } 22 | 23 | public function add(adapter $adapter) 24 | { 25 | if ($this->contains($adapter) === false) 26 | { 27 | $this->adapters->attach($adapter); 28 | } 29 | 30 | return $this; 31 | } 32 | 33 | public function contains(adapter $adapter) 34 | { 35 | return $this->adapters->contains($adapter); 36 | } 37 | 38 | public function reset() 39 | { 40 | $this->adapters = new \splObjectStorage(); 41 | 42 | return $this; 43 | } 44 | 45 | public function getIterator() 46 | { 47 | $adapters = array(); 48 | 49 | foreach ($this->adapters as $instance) 50 | { 51 | $adapters[] = $instance; 52 | } 53 | 54 | return new \arrayIterator($adapters); 55 | } 56 | 57 | public function resetCalls() 58 | { 59 | foreach ($this->adapters as $adapter) 60 | { 61 | $adapter->resetCalls(); 62 | } 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /classes/test/asserter/generator.php: -------------------------------------------------------------------------------- 1 | getLocale(), $resolver, $aliaser); 17 | 18 | $this->test = $test; 19 | } 20 | 21 | public function __get($property) 22 | { 23 | return $this->test->__get($property); 24 | } 25 | 26 | public function __call($method, $arguments) 27 | { 28 | return $this->test->__call($method, $arguments); 29 | } 30 | 31 | public function setTest(atoum\test $test) 32 | { 33 | $this->test = $test; 34 | 35 | return $this->setLocale($test->getLocale()); 36 | } 37 | 38 | public function getTest() 39 | { 40 | return $this->test; 41 | } 42 | 43 | public function getAsserterInstance($asserter, array $arguments = array(), atoum\test $test = null) 44 | { 45 | return parent::getAsserterInstance($asserter, $arguments, $test ?: $this->test); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /classes/test/assertion/manager/exception.php: -------------------------------------------------------------------------------- 1 | setScore(); 22 | } 23 | 24 | public function setScore(atoum\test\score $score = null) 25 | { 26 | $this->score = $score ?: new atoum\test\score(); 27 | 28 | return $this; 29 | } 30 | 31 | public function getScore() 32 | { 33 | return $this->score; 34 | } 35 | 36 | public function run(atoum\test $test) 37 | { 38 | $currentTestMethod = $test->getCurrentMethod(); 39 | 40 | if ($currentTestMethod !== null) 41 | { 42 | $testScore = $test->getScore(); 43 | 44 | $test 45 | ->setScore($this->score->reset()) 46 | ->runTestMethod($currentTestMethod) 47 | ->setScore($testScore) 48 | ; 49 | } 50 | 51 | return $this; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /classes/test/engines/isolate.php: -------------------------------------------------------------------------------- 1 | score = $score ?: new atoum\score(); 22 | 23 | return $this; 24 | } 25 | 26 | public function run(atoum\test $test) 27 | { 28 | parent::run($test); 29 | 30 | $this->score = parent::getScore(); 31 | 32 | while ($this->score === null) 33 | { 34 | $this->score = parent::getScore(); 35 | } 36 | 37 | return $this; 38 | } 39 | 40 | public function getScore() 41 | { 42 | return $this->score; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /classes/test/exceptions/runtime.php: -------------------------------------------------------------------------------- 1 | setTest($test); 19 | } 20 | 21 | public function __get($property) 22 | { 23 | return $this->test->{$property}; 24 | } 25 | 26 | public function __call($method, array $arguments) 27 | { 28 | return call_user_func_array(array($this->test, $method), $arguments); 29 | } 30 | 31 | public function setTest(atoum\test $test) 32 | { 33 | $this->test = $test; 34 | 35 | return $this; 36 | } 37 | 38 | public function getTest() 39 | { 40 | return $this->test; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /classes/tools/diff/decorator.php: -------------------------------------------------------------------------------- 1 | make(), function($value) { return is_array($value) === true; }); 16 | 17 | if (sizeof($diff) > 0) 18 | { 19 | $string .= '-Expected' . PHP_EOL; 20 | $string .= '+Actual' . PHP_EOL; 21 | 22 | foreach ($diff as $lineNumber => $diff) 23 | { 24 | $lineNumber++; 25 | 26 | $sizeofMinus = sizeof($diff['-']); 27 | $sizeofPlus = sizeof($diff['+']); 28 | 29 | $string .= '@@ -' . $lineNumber . ($sizeofMinus <= 1 ? '' : ',' . $sizeofMinus) . ' +' . $lineNumber . ($sizeofPlus <= 1 ? '' : ',' . $sizeofPlus) . ' @@' . PHP_EOL; 30 | 31 | array_walk($diff['-'], function(& $value) { $value = ($value == '' ? '' : '-' . $value); }); 32 | $minus = join(PHP_EOL, $diff['-']); 33 | 34 | if ($minus != '') 35 | { 36 | $string .= $minus . PHP_EOL; 37 | } 38 | 39 | array_walk($diff['+'], function(& $value) { $value = ($value == '' ? '' : '+' . $value); }); 40 | $plus = join(PHP_EOL, $diff['+']); 41 | 42 | if ($plus != '') 43 | { 44 | $string .= $plus . PHP_EOL; 45 | } 46 | } 47 | } 48 | 49 | return trim($string); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /classes/tools/diffs/variable.php: -------------------------------------------------------------------------------- 1 | setAnalyzer(); 17 | 18 | parent::__construct($expected, $actual); 19 | } 20 | 21 | public function setAnalyzer(tools\variable\analyzer $analyzer = null) 22 | { 23 | $this->analyzer = $analyzer ?: new tools\variable\analyzer(); 24 | 25 | return $this; 26 | } 27 | 28 | public function getAnalyzer() 29 | { 30 | return $this->analyzer; 31 | } 32 | 33 | public function setExpected($mixed) 34 | { 35 | return parent::setExpected($this->analyzer->dump($mixed)); 36 | } 37 | 38 | public function setActual($mixed) 39 | { 40 | return parent::setActual($this->analyzer->dump($mixed)); 41 | } 42 | 43 | public function make($expected = null, $actual = null) 44 | { 45 | if ($expected !== null) 46 | { 47 | $this->setExpected($expected); 48 | } 49 | 50 | if ($expected !== null) 51 | { 52 | $this->setActual($actual); 53 | } 54 | 55 | if ($this->expected === null) 56 | { 57 | throw new exceptions\runtime('Expected is undefined'); 58 | } 59 | 60 | if ($this->actual === null) 61 | { 62 | throw new exceptions\runtime('Actual is undefined'); 63 | } 64 | 65 | return parent::make(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /classes/writer.php: -------------------------------------------------------------------------------- 1 | setAdapter($adapter); 17 | } 18 | 19 | public function setAdapter(adapter $adapter = null) 20 | { 21 | $this->adapter = $adapter ?: new adapter(); 22 | 23 | return $this; 24 | } 25 | 26 | public function getAdapter() 27 | { 28 | return $this->adapter; 29 | } 30 | 31 | public function reset() 32 | { 33 | return $this; 34 | } 35 | 36 | public function addDecorator(decorator $decorator) 37 | { 38 | $this->decorators[] = $decorator; 39 | 40 | return $this; 41 | } 42 | 43 | public function getDecorators() 44 | { 45 | return $this->decorators; 46 | } 47 | 48 | public function removeDecorators() 49 | { 50 | $this->decorators = array(); 51 | 52 | return $this; 53 | } 54 | 55 | public function write($string) 56 | { 57 | foreach ($this->decorators as $decorator) 58 | { 59 | $string = $decorator->decorate($string); 60 | } 61 | 62 | $this->doWrite($string); 63 | 64 | return $this; 65 | } 66 | 67 | public abstract function clear(); 68 | 69 | protected abstract function doWrite($string); 70 | } 71 | -------------------------------------------------------------------------------- /classes/writer/decorator.php: -------------------------------------------------------------------------------- 1 | setPrompt($prompt); 18 | } 19 | 20 | public function setPrompt($prompt = null) 21 | { 22 | $this->prompt = $prompt ?: static::defaultPrompt; 23 | 24 | return $this; 25 | } 26 | 27 | public function getPrompt() 28 | { 29 | return $this->prompt; 30 | } 31 | 32 | public function decorate($message) 33 | { 34 | return $this->prompt . $message; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /classes/writer/decorators/rtrim.php: -------------------------------------------------------------------------------- 1 | setCli($cli); 22 | } 23 | 24 | public function __destruct() 25 | { 26 | if ($this->resource !== null) 27 | { 28 | $this->adapter->fclose($this->resource); 29 | } 30 | } 31 | 32 | public function setCli(atoum\cli $cli = null) 33 | { 34 | $this->cli = $cli ?: new atoum\cli(); 35 | 36 | return $this; 37 | } 38 | 39 | public function getCli() 40 | { 41 | return $this->cli; 42 | } 43 | 44 | public function clear() 45 | { 46 | return $this->doWrite($this->cli->isTerminal() === false ? PHP_EOL : "\033[1K\r"); 47 | } 48 | 49 | public function writeRealtimeReport(reports\realtime $report, $event) 50 | { 51 | return $this->write((string) $report); 52 | } 53 | 54 | public function writeAsynchronousReport(reports\asynchronous $report) 55 | { 56 | return $this->write((string) $report); 57 | } 58 | 59 | protected function doWrite($something) 60 | { 61 | $this->init()->adapter->fwrite($this->resource, $something); 62 | 63 | return $this; 64 | } 65 | 66 | protected abstract function init(); 67 | } 68 | -------------------------------------------------------------------------------- /classes/writers/std/err.php: -------------------------------------------------------------------------------- 1 | resource === null) 15 | { 16 | $resource = $this->adapter->fopen('php://stderr', 'w'); 17 | 18 | if ($resource === false) 19 | { 20 | throw new exceptions\runtime('Unable to open php://stderr stream'); 21 | } 22 | 23 | $this->resource = $resource; 24 | } 25 | 26 | return $this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /classes/writers/std/out.php: -------------------------------------------------------------------------------- 1 | resource === null) 15 | { 16 | $resource = $this->adapter->fopen('php://stdout', 'w'); 17 | 18 | if ($resource === false) 19 | { 20 | throw new exceptions\runtime('Unable to open php://stdout stream'); 21 | } 22 | 23 | $this->resource = $resource; 24 | } 25 | 26 | return $this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mageekguy/atoum", 3 | "type": "library", 4 | "description": "The root and a fork of 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-2-Clause", 8 | "authors": 9 | [ 10 | { 11 | "name": "Frédéric Hardy", 12 | "email": "frederic.hardy@atoum.org", 13 | "homepage": "http://blog.mageekbox.net" 14 | }, 15 | { 16 | "name": "François Dussert", 17 | "email": "francois.dussert@atoum.org" 18 | }, 19 | { 20 | "name": "Gérald Croes", 21 | "email": "gerald.croes@atoum.org" 22 | }, 23 | { 24 | "name": "Julien Bianchi", 25 | "email": "julien.bianchi@atoum.org" 26 | }, 27 | { 28 | "name": "Ludovic Fleury", 29 | "email": "ludovic.fleury@atoum.org" 30 | } 31 | ], 32 | "require": 33 | { 34 | "php": ">=5.3.3", 35 | "ext-hash": "*", 36 | "ext-json": "*", 37 | "ext-session": "*", 38 | "ext-tokenizer": "*", 39 | "ext-xml": "*" 40 | }, 41 | "bin": 42 | [ 43 | "bin/atoum" 44 | ], 45 | "autoload": 46 | { 47 | "classmap": [ "classes/" ] 48 | }, 49 | "suggest": { 50 | "ext-mbstring": "Provides support for UTF-8 strings" 51 | }, 52 | "extra": { 53 | "branch-alias": { 54 | "dev-master": "1.x-dev" 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /constants.php: -------------------------------------------------------------------------------- 1 | setWorkingDirectory('/path/to/working/directory') 7 | ->setDestinationDirectory('/path/to/destination/directory') 8 | ->setScoreDirectory('/path/to/scores/directory') 9 | ->setErrorsDirectory('/path/to/errors/directory') 10 | ->setRevisionFile('/path/to/revision/file') 11 | ->addRunnerConfigurationFile('/path/to/runner/configuration/file') 12 | ->setTaggerEngine(new atoum\scripts\tagger\engine()) 13 | ->setReportTitle('[%3$s] Nightly build of revision %4$s the %1$s at %2$s') 14 | ; 15 | -------------------------------------------------------------------------------- /resources/configurations/runner/bootstrap.php.dist: -------------------------------------------------------------------------------- 1 | addTo('to@domain') 12 | ->setFrom('from@domain') 13 | ->setXMailer('atoum builder') 14 | ->setReplyTo('reply@domain') 15 | ->setContentType('text/plain', 'utf-8') 16 | ; 17 | 18 | $mailWriter = new atoum\writers\mail(); 19 | $mailWriter 20 | ->setMailer($mailer) 21 | ; 22 | 23 | $builderReport = new atoum\reports\asynchronous\builder(); 24 | $builderReport 25 | ->addWriter($mailWriter) 26 | ; 27 | 28 | $runner->addReport($builderReport); 29 | -------------------------------------------------------------------------------- /resources/configurations/runner/cli.php.dist: -------------------------------------------------------------------------------- 1 | addWriter($stdOutWriter); 20 | 21 | $runner->addReport($cliReport); 22 | -------------------------------------------------------------------------------- /resources/configurations/runner/clover.php.dist: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 14 | 15 | /* 16 | Please replace in next line /path/to/destination/directory/atoum.coverage.xml by your output file for clover report. 17 | */ 18 | $cloverWriter = new atoum\writers\file('/path/to/destination/directory/atoum.coverage.xml'); 19 | 20 | /* 21 | Generate a clover XML report. 22 | */ 23 | $cloverReport = new atoum\reports\asynchronous\clover(); 24 | $cloverReport->addWriter($cloverWriter); 25 | 26 | $runner->addReport($cloverReport); 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /resources/configurations/runner/coverage.php.dist: -------------------------------------------------------------------------------- 1 | setRootUrl('http://url/of/web/site'); 21 | 22 | // Treemap (not mandatory) 23 | 24 | /* 25 | Please replace in next line /path/to/destination/directory by your destination directory path for html files. 26 | */ 27 | $coverageTreemapField = new atoum\report\fields\runner\coverage\treemap('Your project name', '/path/to/destination/directory'); 28 | 29 | /* 30 | Please replace in next line http://url/of/treemap by the root url of your treemap web site. 31 | */ 32 | $coverageTreemapField 33 | ->setTreemapUrl('http://url/of/treemap') 34 | ->setHtmlReportBaseUrl($coverageHtmlField->getRootUrl()) 35 | ; 36 | 37 | $script 38 | ->addDefaultReport() 39 | ->addField($coverageHtmlField) 40 | ->addField($coverageTreemapField) 41 | ; 42 | -------------------------------------------------------------------------------- /resources/configurations/runner/coveralls.php.dist: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 17 | 18 | /* 19 | Publish code coverage report on coveralls.io 20 | */ 21 | $sources = '/path/to/sources/directory'; 22 | $token = 'YouCoverallsProjectToken'; 23 | $coverallsReport = new reports\asynchronous\coveralls($sources, $token); 24 | 25 | /* 26 | If you are using Travis-CI (or any other CI tool), you should customize the report 27 | * https://coveralls.io/docs/api 28 | * http://about.travis-ci.org/docs/user/ci-environment/#Environment-variables 29 | * https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables 30 | */ 31 | $defaultFinder = $coverallsReport->getBranchFinder(); 32 | $coverallsReport 33 | ->setBranchFinder(function() use ($defaultFinder) { 34 | if (($branch = getenv('TRAVIS_BRANCH')) === false) 35 | { 36 | $branch = $defaultFinder(); 37 | } 38 | 39 | return $branch; 40 | }) 41 | ->setServiceName(getenv('TRAVIS') ? 'travis-ci' : null) 42 | ->setServiceJobId(getenv('TRAVIS_JOB_ID') ?: null) 43 | ->addDefaultWriter() 44 | ; 45 | 46 | $runner->addReport($coverallsReport); 47 | -------------------------------------------------------------------------------- /resources/configurations/runner/logo.php.dist: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 14 | 15 | /* 16 | This will add the atoum logo before each run 17 | */ 18 | $cliReport->addField(new atoum\report\fields\runner\atoum\logo()); 19 | 20 | /* 21 | This will add a green or red logo after each run depending on its status 22 | */ 23 | $cliReport->addField(new atoum\report\fields\runner\result\logo()); 24 | 25 | $runner->addReport($cliReport); 26 | -------------------------------------------------------------------------------- /resources/configurations/runner/santa.php.dist: -------------------------------------------------------------------------------- 1 | addWriter($stdOutWriter); 20 | 21 | $runner->addReport($cliReport); 22 | -------------------------------------------------------------------------------- /resources/configurations/runner/vim.php.dist: -------------------------------------------------------------------------------- 1 | addWriter($stdOutWriter); 19 | 20 | $runner->addReport($vimReport); 21 | -------------------------------------------------------------------------------- /resources/configurations/runner/xunit.php.dist: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 14 | 15 | /* 16 | Please replace in next line /path/to/destination/directory/atoum.xunit.xml by your output file for xUnit report. 17 | */ 18 | $xunitWriter = new atoum\writers\file('/path/to/destination/directory/atoum.xunit.xml'); 19 | 20 | /* 21 | Generate a xUnit report. 22 | */ 23 | $xunitReport = new atoum\reports\asynchronous\xunit(); 24 | $xunitReport->addWriter($xunitWriter); 25 | 26 | $runner->addReport($xunitReport); 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /resources/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageekguy/atoum/41d2d36e19ce515a91a24ee7ad9350d1a8ebae7b/resources/images/logo.png -------------------------------------------------------------------------------- /resources/images/logo/failure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageekguy/atoum/41d2d36e19ce515a91a24ee7ad9350d1a8ebae7b/resources/images/logo/failure.png -------------------------------------------------------------------------------- /resources/images/logo/success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageekguy/atoum/41d2d36e19ce515a91a24ee7ad9350d1a8ebae7b/resources/images/logo/success.png -------------------------------------------------------------------------------- /resources/phing/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /resources/sonar/maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | [GROUP ID] 4 | [ARTIFACT ID] 5 | [PROJECT NAME] 6 | [PROJECT VERSION] 7 | 8 | pom 9 | 10 | 11 | 12 | ${basedir}/src 13 | 14 | ${basedir}/test 15 | 16 | 17 | 18 | php 19 | [EXCLUDE PATTERNS] 20 | 21 | true 22 | true 23 | false 24 | 25 | false 26 | false 27 | atoum.phar 28 | 29 | 30 | ${basedir}/.atoum.php 31 | 32 | ${basedir}/.atoum.bootstrap.php 33 | 34 | -------------------------------------------------------------------------------- /resources/templates/test/generator/testClass.php: -------------------------------------------------------------------------------- 1 | ; 4 | 5 | use 6 | mageekguy\atoum, 7 | as testedClass 8 | ; 9 | 10 | require_once __DIR__ . '/'; 11 | 12 | class extends atoum\test 13 | { 14 | public function test() 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/templates/test/generator/testedClass.php: -------------------------------------------------------------------------------- 1 | ; 4 | 5 | class 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /scripts/builder.php: -------------------------------------------------------------------------------- 1 | writeError($message); 16 | 17 | exit($error); 18 | } 19 | } 20 | ); 21 | 22 | try 23 | { 24 | $builder->run(); 25 | } 26 | catch (\exception $exception) 27 | { 28 | $builder->writeError($exception->getMessage()); 29 | 30 | exit($exception->getCode()); 31 | } 32 | 33 | exit(0); 34 | -------------------------------------------------------------------------------- /scripts/compiler.php: -------------------------------------------------------------------------------- 1 | writeError($message); 16 | 17 | exit($error); 18 | } 19 | } 20 | ); 21 | 22 | try 23 | { 24 | $compiler->run(); 25 | } 26 | catch (\exception $exception) 27 | { 28 | $compiler->writeError($exception->getMessage()); 29 | 30 | exit($exception->getCode()); 31 | } 32 | 33 | exit(0); 34 | -------------------------------------------------------------------------------- /scripts/coverage.php: -------------------------------------------------------------------------------- 1 | writeError($message); 17 | 18 | exit($error); 19 | } 20 | } 21 | ); 22 | 23 | try 24 | { 25 | $coverage->run(); 26 | } 27 | catch (\exception $exception) 28 | { 29 | $coverage->writeError($exception->getMessage()); 30 | 31 | exit($exception->getCode()); 32 | } 33 | 34 | exit(0); 35 | -------------------------------------------------------------------------------- /scripts/git/.tag: -------------------------------------------------------------------------------- 1 | 2.0.0 -------------------------------------------------------------------------------- /scripts/git/pusher.php: -------------------------------------------------------------------------------- 1 | writeError($message); 19 | 20 | exit($error); 21 | } 22 | } 23 | ); 24 | 25 | try 26 | { 27 | $pusher->run(); 28 | } 29 | catch (\exception $exception) 30 | { 31 | $pusher->writeError($exception->getMessage()); 32 | 33 | exit($exception->getCode()); 34 | } 35 | 36 | exit(0); 37 | -------------------------------------------------------------------------------- /scripts/phar/generator.php: -------------------------------------------------------------------------------- 1 | setOriginDirectory(__DIR__ . '/../..'); 12 | $generator->setStubFile(__DIR__ . '/resources/stub.php'); 13 | 14 | set_error_handler(function($error, $message, $file, $line) use ($generator) { 15 | if (error_reporting() !== 0) 16 | { 17 | $generator->writeError($message); 18 | 19 | exit($error); 20 | } 21 | } 22 | ); 23 | 24 | try 25 | { 26 | $generator->run(); 27 | } 28 | catch (\exception $exception) 29 | { 30 | $generator->writeError($exception->getMessage()); 31 | 32 | exit($exception->getCode()); 33 | } 34 | 35 | exit(0); 36 | -------------------------------------------------------------------------------- /scripts/phar/resources/stub.php: -------------------------------------------------------------------------------- 1 | writeError($message); 17 | 18 | exit($error); 19 | } 20 | } 21 | ); 22 | 23 | try 24 | { 25 | $tagger->run(); 26 | } 27 | catch (\exception $exception) 28 | { 29 | $tagger->writeError($exception->getMessage()); 30 | 31 | exit($exception->getCode()); 32 | } 33 | 34 | exit(0); 35 | -------------------------------------------------------------------------------- /scripts/treemap.php: -------------------------------------------------------------------------------- 1 | writeError($message); 17 | 18 | exit($error); 19 | } 20 | } 21 | ); 22 | 23 | try 24 | { 25 | $treemap->setHtmlDirectory(atoum\directory . '/resources/treemap')->run(); 26 | } 27 | catch (\exception $exception) 28 | { 29 | $treemap->writeError($exception->getMessage()); 30 | 31 | exit($exception->getCode()); 32 | } 33 | 34 | exit(0); 35 | -------------------------------------------------------------------------------- /tests/units/.atoum.php: -------------------------------------------------------------------------------- 1 | addTestsFromDirectory(__DIR__ . '/classes'); 4 | -------------------------------------------------------------------------------- /tests/units/asserters/template/parser/exception.php: -------------------------------------------------------------------------------- 1 | valueIsSet()->value->getErrorLine() === $line) 14 | { 15 | return $this->pass(); 16 | } 17 | else 18 | { 19 | $this->fail($failMessage !== null ? $failMessage : sprintf($this->getLocale()->_('Line is %s instead of %s'), $this->value->getErrorLine(), $line)); 20 | } 21 | } 22 | 23 | public function hasErrorOffset($offset, $failMessage = null) 24 | { 25 | if ($this->valueIsSet()->value->getErrorOffset() === $offset) 26 | { 27 | return $this->pass(); 28 | } 29 | else 30 | { 31 | $this->fail($failMessage !== null ? $failMessage : sprintf($this->getLocale()->_('Offset is %s instead of %s'), $this->value->getErrorOffset(), $offset)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/units/classes/adapter.php: -------------------------------------------------------------------------------- 1 | string($this->newTestedInstance->md5($hash = uniqid()))->isEqualTo(md5($hash)); 17 | } 18 | 19 | public function testInvoke() 20 | { 21 | $this->string($this->newTestedInstance->invoke('md5', array($hash = uniqid())))->isEqualTo(md5($hash)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/adapter/call/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\logic'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/adapter/call/manager.php: -------------------------------------------------------------------------------- 1 | given($manager = $this->newTestedInstance) 17 | ->then 18 | ->object($this->testedInstance->add($call = new \mock\atoum\asserters\adapter\call()))->isTestedInstance 19 | ->object($this->testedInstance->add($call))->isTestedInstance 20 | ; 21 | } 22 | 23 | public function testRemove() 24 | { 25 | $this 26 | ->given($this->newTestedInstance) 27 | ->then 28 | ->object($this->testedInstance->remove($call = new \mock\atoum\asserters\adapter\call()))->isTestedInstance 29 | ->object($this->testedInstance->add($call = new \mock\atoum\asserters\adapter\call()))->isTestedInstance 30 | ; 31 | } 32 | 33 | public function testCheck() 34 | { 35 | $this 36 | ->given($manager = $this->newTestedInstance) 37 | ->then 38 | ->object($this->testedInstance->check())->isTestedInstance 39 | 40 | ->if( 41 | $this->testedInstance->add($call = new \mock\atoum\asserters\adapter\call()), 42 | $this->calling($call)->getLastAssertionFile = $file = uniqid(), 43 | $this->calling($call)->getLastAssertionLine = $line = rand(1, PHP_INT_MAX) 44 | ) 45 | ->then 46 | ->exception(function() use ($manager) { $manager->check(); }) 47 | ->isInstanceOf('mageekguy\atoum\asserters\adapter\call\manager\exception') 48 | ->hasMessage('Asserter ' . get_class($call) . ' is not evaluated in file \'' . $file . '\' on line ' . $line); 49 | ; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/adapter/call/manager/exception.php: -------------------------------------------------------------------------------- 1 | testedClass 14 | ->extends('runtimeException') 15 | ->implements('mageekguy\atoum\exception') 16 | ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/adapter/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\logic'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/mock/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\logic'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/mysqlDateTime.php: -------------------------------------------------------------------------------- 1 | testedClass->isSubclassOf('mageekguy\atoum\asserters\dateTime'); 18 | } 19 | 20 | public function testSetWith() 21 | { 22 | $this 23 | ->given($asserter = $this->newTestedInstance) 24 | 25 | ->if( 26 | $asserter 27 | ->setLocale($locale = new \mock\atoum\locale()) 28 | ->setAnalyzer($analyzer = new \mock\atoum\tools\variable\analyzer()), 29 | $this->calling($locale)->_ = $notMysqlDateTime = uniqid(), 30 | $this->calling($analyzer)->getTypeOf = $type = uniqid() 31 | ) 32 | ->then 33 | ->exception(function() use ($asserter, & $value) { $asserter->setWith($value = uniqid()); }) 34 | ->isInstanceOf('mageekguy\atoum\asserter\exception') 35 | ->hasMessage($notMysqlDateTime) 36 | ->mock($locale)->call('_')->withArguments('%s is not in format Y-m-d H:i:s', $type)->once 37 | ->mock($analyzer)->call('getTypeOf')->withArguments($value)->once 38 | ->string($asserter->getValue())->isEqualTo($value) 39 | 40 | ->object($asserter->setWith($value = '1976-10-06 14:05:54'))->isIdenticalTo($asserter) 41 | ->string($asserter->getValue())->isIdenticalTo($value) 42 | ->object($asserter->setWith($value = uniqid(), false))->isIdenticalTo($asserter) 43 | ->string($asserter->getValue())->isEqualTo($value) 44 | ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/units/classes/asserters/testedClass.php: -------------------------------------------------------------------------------- 1 | testedClass->isSubclassOf('mageekguy\atoum\asserters\phpClass'); 18 | } 19 | 20 | public function testSetWith() 21 | { 22 | $this 23 | ->if($asserter = new asserters\testedClass(new asserter\generator())) 24 | ->then 25 | ->exception(function() use ($asserter) { $asserter->setWith(uniqid()); }) 26 | ->isInstanceOf('mageekguy\atoum\exceptions\logic\badMethodCall') 27 | ->hasMessage('Unable to call method ' . get_class($asserter) . '::setWith()') 28 | ; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/units/classes/cli/clear.php: -------------------------------------------------------------------------------- 1 | testedClass->implements('mageekguy\atoum\writer\decorator'); 17 | } 18 | 19 | public function test__construct() 20 | { 21 | $this 22 | ->if($clear = new testedClass()) 23 | ->then 24 | ->object($clear->getCli())->isEqualTo(new atoum\cli()) 25 | ; 26 | } 27 | 28 | public function testSetCli() 29 | { 30 | $this 31 | ->if($clear = new testedClass()) 32 | ->then 33 | ->object($clear->setCli($cli = new atoum\cli()))->isIdenticalTo($clear) 34 | ->object($clear->getCli())->isIdenticalTo($cli) 35 | ->object($clear->setCli())->isIdenticalTo($clear) 36 | ->object($clear->getCli()) 37 | ->isNotIdenticalTo($cli) 38 | ->isEqualTo(new atoum\cli()) 39 | ; 40 | } 41 | 42 | public function testDecorate() 43 | { 44 | $this 45 | ->given( 46 | $clear = new testedClass($cli = new \mock\mageekguy\atoum\cli()) 47 | ) 48 | ->if($this->calling($cli)->isTerminal = false) 49 | ->then 50 | ->string($clear->decorate(''))->isEqualTo(PHP_EOL) 51 | ->string($clear->decorate($message = uniqid()))->isEqualTo(PHP_EOL . $message) 52 | ->if($this->calling($cli)->isTerminal = true) 53 | ->then 54 | ->string($clear->decorate(''))->isEqualTo("\033[1K\r") 55 | ->string($clear->decorate($message = uniqid()))->isEqualTo("\033[1K\r" . $message) 56 | ; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /tests/units/classes/cli/command/exception.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\runtime'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/exceptions/logic.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('logicException') 19 | ->implements('mageekguy\atoum\exception') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/exceptions/logic/badMethodCall.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('logicException') 19 | ->extends('badMethodCallException') 20 | ->implements('mageekguy\atoum\exception') 21 | ; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/units/classes/exceptions/logic/invalidArgument.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('logicException') 19 | ->extends('invalidArgumentException') 20 | ->implements('mageekguy\atoum\exception') 21 | ; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/units/classes/exceptions/runtime.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('runtimeException') 19 | ->implements('mageekguy\atoum\exception') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/exceptions/runtime/unexpectedValue.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('runtimeException') 19 | ->extends('unexpectedValueException') 20 | ->implements('mageekguy\atoum\exception') 21 | ; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/units/classes/fs/path/exception.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\runtime'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/iterators/filters/recursives/atoum/source.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\iterators\filters\recursives\dot'); 18 | } 19 | 20 | public function test__accept() 21 | { 22 | $this 23 | ->mockGenerator->shunt('__construct') 24 | ->if($iteratorController = new mock\controller()) 25 | ->and($iteratorController->__construct = function() {}) 26 | ->and($filter = new recursives\atoum\source(new \mock\recursiveDirectoryIterator(uniqid()))) 27 | ->and($iteratorController->current = new \splFileInfo(uniqid())) 28 | ->then 29 | ->boolean($filter->accept())->isTrue() 30 | ->if($iteratorController->current = new \splFileInfo('.' . uniqid())) 31 | ->then 32 | ->boolean($filter->accept())->isFalse() 33 | ->if($iteratorController->current = new \splFileInfo(uniqid() . DIRECTORY_SEPARATOR . '.' . uniqid())) 34 | ->then 35 | ->boolean($filter->accept())->isFalse() 36 | ->if($iteratorController->current = new \splFileInfo(uniqid() . DIRECTORY_SEPARATOR . 'GPATH')) 37 | ->then 38 | ->boolean($filter->accept())->isFalse() 39 | ->if($iteratorController->current = new \splFileInfo(uniqid() . DIRECTORY_SEPARATOR . 'GRTAGS')) 40 | ->then 41 | ->boolean($filter->accept())->isFalse() 42 | ->if($iteratorController->current = new \splFileInfo(uniqid() . DIRECTORY_SEPARATOR . 'GTAGS')) 43 | ->then 44 | ->boolean($filter->accept())->isFalse() 45 | ; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/units/classes/iterators/filters/recursives/closure.php: -------------------------------------------------------------------------------- 1 | if($filter = new testedClass(new \recursiveArrayIterator(array()))) 18 | ->then 19 | ->object($filter->addClosure($closure = function() {}))->isIdenticalTo($filter) 20 | ->array($filter->getClosures())->isEqualTo(array($closure)) 21 | ->object($filter->addClosure($otherClosure = function() {}))->isIdenticalTo($filter) 22 | ->array($filter->getClosures())->isEqualTo(array($closure, $otherClosure)) 23 | ; 24 | } 25 | 26 | public function testAccept() 27 | { 28 | $this 29 | ->if($array = array( 30 | 0, 31 | 1, 32 | 2, 33 | array( 34 | 3, 35 | array( 36 | 4, 37 | 5 38 | ), 39 | 6 40 | ), 41 | 7, 42 | 8, 43 | 9 44 | ) 45 | ) 46 | ->and($iterator = new \recursiveIteratorIterator( 47 | new testedClass( 48 | new \recursiveArrayIterator($array), 49 | function($current, $key, \recursiveArrayIterator $innerIterator) 50 | { 51 | if (true === $innerIterator->hasChildren()) 52 | { 53 | return true; 54 | } 55 | 56 | return (0 === $current % 2); 57 | } 58 | ) 59 | ) 60 | ) 61 | ->then 62 | ->array(iterator_to_array($iterator, false)) 63 | ->hasSize(5) 64 | ->strictlyContainsValues(array(0, 2, 4, 6, 8)) 65 | ->strictlyNotContainsValues(array(1, 3, 5, 7, 9)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/units/classes/mock/controller/invoker.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\test\adapter\invoker'); 16 | } 17 | 18 | public function test__construct() 19 | { 20 | $this 21 | ->given($this->newTestedInstance($method = uniqid())) 22 | ->then 23 | ->string($this->testedInstance->getFunction())->isEqualTo($method) 24 | ->variable($this->testedInstance->getMock())->isNull() 25 | 26 | ->given($this->newTestedInstance($method = uniqid(), $mock = new \mock\foo())) 27 | ->then 28 | ->string($this->testedInstance->getFunction())->isEqualTo($method) 29 | ->object($this->testedInstance->getMock())->isIdenticalTo($mock) 30 | ; 31 | } 32 | 33 | public function testIsFluent() 34 | { 35 | $this 36 | ->if($this->newTestedInstance($method = uniqid(), $mock = new \mock\foo())) 37 | ->then 38 | ->object($this->testedInstance->isFluent())->isTestedInstance 39 | ->object($this->testedInstance->invoke())->isIdenticalTo($mock) 40 | 41 | ->if($this->newTestedInstance($method = uniqid(), $mock = new \mock\foo())) 42 | ->then 43 | ->object($this->testedInstance->isFluent)->isTestedInstance 44 | ->object($this->testedInstance->invoke())->isIdenticalTo($mock) 45 | ; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/units/classes/mock/generator/method/exception.php: -------------------------------------------------------------------------------- 1 | testedClass 16 | ->extends('exception') 17 | ->implements('mageekguy\atoum\exception') 18 | ; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/units/classes/mock/stream/invoker.php: -------------------------------------------------------------------------------- 1 | testedClass->isSubclassOf('mageekguy\atoum\test\adapter\invoker'); 17 | } 18 | 19 | public function test__construct() 20 | { 21 | $this 22 | ->if($invoker = new stream\invoker($methodName = uniqid())) 23 | ->then 24 | ->string($invoker->getMethodName())->isEqualTo($methodName) 25 | ; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/units/classes/mock/streams/fs/controller/factory.php: -------------------------------------------------------------------------------- 1 | given($factory = new testedClass()) 19 | ->then 20 | ->object($factory->build($name = uniqid()))->isEqualTo(new controller($name)) 21 | ; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/units/classes/mock/streams/fs/directory.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\mock\stream'); 18 | } 19 | 20 | public function testMkdir() 21 | { 22 | $this 23 | ->if($directory = testedClass::get()) 24 | ->and($directory->notExists()) 25 | ->then 26 | ->boolean(mkdir($directory, 0777))->isTrue() 27 | ->integer($directory->getPermissions())->isEqualTo(0777) 28 | ->boolean(mkdir($directory, 0777))->isFalse() 29 | ->if($directory->notExists()) 30 | ->then 31 | ->boolean(mkdir($directory, 0007))->isTrue() 32 | ->integer($directory->getPermissions())->isEqualTo(0007) 33 | ; 34 | } 35 | 36 | public function testRmdir() 37 | { 38 | $this 39 | ->if($directory = testedClass::get()) 40 | ->and($directory->notExists()) 41 | ->then 42 | ->boolean(rmdir($directory))->isFalse() 43 | ->if($directory->exists()) 44 | ->then 45 | ->boolean(rmdir($directory))->isTrue() 46 | ->if($directory->exists()) 47 | ->and($directory->isNotWritable()) 48 | ->then 49 | ->boolean(rmdir($directory))->isFalse() 50 | ; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/units/classes/php/exception.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\runtime'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/php/mocker/adapter.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\test\adapter'); 18 | } 19 | 20 | public function test__get() 21 | { 22 | $this 23 | ->if($adapter = new testedClass()) 24 | ->then 25 | ->object($invoker = $adapter->md5)->isEqualTo(new mocker\adapter\invoker('md5')) 26 | ->object($adapter->md5)->isIdenticalTo($invoker) 27 | ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/units/classes/php/mocker/adapter/invoker.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\test\adapter\invoker'); 17 | } 18 | 19 | public function testInvoke() 20 | { 21 | $this 22 | ->if($invoker = new testedClass(uniqid())) 23 | ->then 24 | ->exception(function() use ($invoker) { 25 | $invoker->invoke(); 26 | } 27 | ) 28 | ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument') 29 | ->hasMessage('There is no closure defined for call 0') 30 | ->if($invoker->setClosure(function($string) { return md5($string); })) 31 | ->and($invoker->setClosure(function() use (& $md5) { return $md5 = uniqid(); }, 1)) 32 | ->and($invoker->setClosure(function() use (& $md5) { return $md5 = uniqid(); }, $call = rand(2, PHP_INT_MAX))) 33 | ->then 34 | ->string($invoker->invoke(array($string = uniqid())))->isEqualTo(md5($string)) 35 | ->string($invoker->invoke(array($string = uniqid()), 0))->isEqualTo(md5($string)) 36 | ->string($invoker->invoke(array($string = uniqid()), 1))->isEqualTo($md5) 37 | ->string($invoker->invoke(array($string = uniqid())))->isEqualTo(md5($string)) 38 | ->string($invoker->invoke(array($string = uniqid()), 0))->isEqualTo(md5($string)) 39 | ->string($invoker->invoke(array($string = uniqid()), $call))->isEqualTo($md5) 40 | ; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpArgument.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterator') 20 | ; 21 | } 22 | 23 | public function test__construct() 24 | { 25 | $this 26 | ->if($this->newTestedInstance) 27 | ->then 28 | ->variable($this->testedInstance->getDefaultValue())->isNull() 29 | ; 30 | } 31 | 32 | public function testAppendDefaultValue() 33 | { 34 | $this 35 | ->if($this->newTestedInstance) 36 | ->then 37 | ->object($this->testedInstance->appendDefaultValue($defaultValue = new iterators\phpDefaultValue()))->isTestedInstance 38 | ->object($this->testedInstance->getDefaultValue())->isIdenticalTo($defaultValue) 39 | ; 40 | } 41 | 42 | public function testGetDefaultValue() 43 | { 44 | $this 45 | ->if($this->newTestedInstance) 46 | ->then 47 | ->variable($this->testedInstance->getDefaultValue())->isNull() 48 | ; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpConstant.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterator') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpImportation.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterator') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpMethod.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterators\phpFunction') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpNamespace.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterator') 20 | ; 21 | } 22 | 23 | public function testAppendClass() 24 | { 25 | $this 26 | ->if( 27 | $this->newTestedInstance, 28 | $phpClass = new iterators\phpClass(), 29 | $phpClass 30 | ->append($token1 = new tokenizer\token(uniqid())) 31 | ->append($token2 = new tokenizer\token(uniqid())) 32 | ) 33 | ->object($this->testedInstance->appendClass($phpClass))->isTestedInstance 34 | ->array($this->testedInstance->getClasses())->isEqualTo(array($phpClass)) 35 | ->castToString($this->testedInstance)->isEqualTo($token1 . $token2) 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/units/classes/php/tokenizer/iterators/phpProperty.php: -------------------------------------------------------------------------------- 1 | testedClass 19 | ->isSubClassOf('mageekguy\atoum\php\tokenizer\iterator') 20 | ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/units/classes/reader.php: -------------------------------------------------------------------------------- 1 | testedClass->isAbstract(); 16 | } 17 | 18 | public function test__construct() 19 | { 20 | $this 21 | ->if($this->newTestedInstance) 22 | ->then 23 | ->object($this->testedInstance->getAdapter())->isEqualTo(new atoum\adapter()) 24 | ->if($this->newTestedInstance($adapter = new atoum\adapter())) 25 | ->then 26 | ->object($this->testedInstance->getAdapter())->isIdenticalTo($adapter) 27 | ; 28 | } 29 | 30 | public function testSetAdapter() 31 | { 32 | $this 33 | ->if($this->newTestedInstance) 34 | ->then 35 | ->object($this->testedInstance->setAdapter($adapter = new atoum\adapter()))->isTestedInstance 36 | ->object($this->testedInstance->getAdapter())->isIdenticalTo($adapter) 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/units/classes/readers/std/in.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\reader'); 17 | } 18 | 19 | public function testRead() 20 | { 21 | $this 22 | ->given($reader = new testedClass($adapter = new atoum\test\adapter())) 23 | ->if($adapter->fopen = false) 24 | ->then 25 | ->exception(function() use ($reader) { $reader->read(); }) 26 | ->isInstanceOf('mageekguy\atoum\exceptions\runtime') 27 | ->hasMessage('Unable to open php://stdin stream') 28 | ->adapter($adapter) 29 | ->call('fopen')->withArguments('php://stdin', 'r')->once() 30 | ->if($adapter->fopen = $resource = uniqid()) 31 | ->and($adapter->fgets = $line = uniqid()) 32 | ->then 33 | ->string($reader->read())->isEqualTo($line) 34 | ->adapter($adapter) 35 | ->call('fopen')->withArguments('php://stdin', 'r')->twice() 36 | ->call('fgets')->withArguments($resource)->once() 37 | ->string($reader->read($length = rand(1, PHP_INT_MAX)))->isEqualTo($line) 38 | ->adapter($adapter)->call('fgets')->withArguments($resource, $length)->once() 39 | ; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/units/classes/report/field.php: -------------------------------------------------------------------------------- 1 | testedClass->isAbstract(); 17 | } 18 | 19 | public function test__construct() 20 | { 21 | $this 22 | ->if($field = new \mock\mageekguy\atoum\report\field()) 23 | ->then 24 | ->variable($field->getEvents())->isNull() 25 | ->object($field->getLocale())->isEqualTo(new atoum\locale()) 26 | ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/units/classes/report/fields/runner/tap/plan.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\report\field'); 18 | } 19 | 20 | public function test__construct() 21 | { 22 | $this 23 | ->if($field = new testedClass()) 24 | ->then 25 | ->array($field->getEvents())->isEqualTo(array(runner::runStart)) 26 | ; 27 | } 28 | 29 | public function test__toString() 30 | { 31 | $this 32 | ->if($runner = new \mock\mageekguy\atoum\runner()) 33 | ->and($this->calling($runner)->getTestMethodNumber = $testMethodNumber = rand(1, PHP_INT_MAX)) 34 | ->and($field = new testedClass()) 35 | ->if($field->handleEvent(runner::runStop, $runner)) 36 | ->then 37 | ->castToString($field)->isEmpty() 38 | ->if($field->handleEvent(runner::runStart, $runner)) 39 | ->then 40 | ->castToString($field)->isEqualTo('1..' . $testMethodNumber . PHP_EOL) 41 | ; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/units/classes/report/fields/runner/tests/skipped.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('mageekguy\atoum\report\field') 19 | ->isAbstract() 20 | ; 21 | } 22 | 23 | public function test__construct() 24 | { 25 | $this 26 | ->if($field = new testedClass()) 27 | ->then 28 | ->variable($field->getRunner())->isNull() 29 | ->array($field->getEvents())->isEqualTo(array(runner::runStop)) 30 | ; 31 | } 32 | 33 | public function testHandleEvent() 34 | { 35 | $this 36 | ->if($field = new testedClass()) 37 | ->and($runner = new atoum\runner()) 38 | ->then 39 | ->boolean($field->handleEvent(runner::runStart, $runner))->isFalse() 40 | ->variable($field->getRunner())->isNull() 41 | ->boolean($field->handleEvent(runner::runStop, $runner))->isTrue() 42 | ->object($field->getRunner())->isIdenticalTo($runner) 43 | ; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/units/classes/report/fields/runner/tests/void.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('mageekguy\atoum\report\field') 19 | ->isAbstract() 20 | ; 21 | } 22 | 23 | public function test__construct() 24 | { 25 | $this 26 | ->if($field = new testedClass()) 27 | ->then 28 | ->variable($field->getRunner())->isNull() 29 | ->array($field->getEvents())->isEqualTo(array(runner::runStop)) 30 | ; 31 | } 32 | 33 | public function testHandleEvent() 34 | { 35 | $this 36 | ->if($field = new testedClass()) 37 | ->and($runner = new atoum\runner()) 38 | ->then 39 | ->boolean($field->handleEvent(runner::runStart, $runner))->isFalse() 40 | ->variable($field->getRunner())->isNull() 41 | ->boolean($field->handleEvent(runner::runStop, $runner))->isTrue() 42 | ->object($field->getRunner())->isIdenticalTo($runner) 43 | ; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/clover/resources/1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/coveralls/resources/1.json: -------------------------------------------------------------------------------- 1 | {"service_name":"atoum","service_event_type":"manual","service_job_id":null,"repo_token":"51bb597d202b4","run_at":"2013-05-13 10:00:00 +0000","source_files":[],"git":{"head":{"id":"7282ea7620b45fcba0f9d3bfd484ab146aba2bd0","author_name":"mageekguy","author_email":"atoum@atoum.org","comitter_name":"mageekguy","comitter_email":"atoum@atoum.org"},"branch":"master"}} -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/coveralls/resources/2.json: -------------------------------------------------------------------------------- 1 | {"service_name":"atoum","service_event_type":"manual","service_job_id":null,"repo_token":"51bb597d202b4","run_at":"2013-05-13 10:00:00 +0000","source_files":[{"name":"foo\/bar.php","source":"testedClass->extends('mageekguy\atoum\reports\asynchronous'); 17 | } 18 | 19 | public function test__construct() 20 | { 21 | $this 22 | ->if($report = new asynchronous\vim()) 23 | ->then 24 | ->object($report->getLocale())->isEqualTo(new atoum\locale()) 25 | ->object($report->getAdapter())->isEqualTo(new atoum\adapter()) 26 | ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/xunit/resources/1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/xunit/resources/2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/units/classes/reports/asynchronous/xunit/resources/3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/units/classes/reports/realtime.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\report'); 16 | } 17 | 18 | public function testIsOverridableBy() 19 | { 20 | $this 21 | ->if($report = new \mock\mageekguy\atoum\reports\realtime()) 22 | ->and($otherRealtimeReport = new \mock\mageekguy\atoum\reports\realtime()) 23 | ->and($otherReport = new \mock\mageekguy\atoum\report()) 24 | ->then 25 | ->boolean($report->isOverridableBy($report))->isFalse 26 | ->boolean($report->isOverridableBy($otherRealtimeReport))->isFalse 27 | ->boolean($report->isOverridableBy($otherReport))->isTrue 28 | ; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/units/classes/reports/realtime/tap.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('mageekguy\atoum\reports\realtime') 19 | ; 20 | } 21 | 22 | public function test__construct() 23 | { 24 | $this 25 | ->define($planField = new fields\runner\tap\plan()) 26 | ->define($eventField = new fields\test\event\tap()) 27 | ->if($report = new testedClass()) 28 | ->then 29 | ->object($report->getLocale())->isEqualTo(new atoum\locale()) 30 | ->object($report->getAdapter())->isEqualTo(new atoum\adapter()) 31 | ->array($report->getFields())->isEqualTo(array( 32 | $planField, 33 | $eventField 34 | ) 35 | ) 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/units/classes/scripts/git/.tag: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /tests/units/classes/test/adapter/call/arguments/decorator.php: -------------------------------------------------------------------------------- 1 | if($decorator = new testedClass()) 19 | ->then 20 | ->string($decorator->decorate())->isEmpty() 21 | ->string($decorator->decorate(null))->isEmpty() 22 | ->string($decorator->decorate(array()))->isEmpty() 23 | ->string($decorator->decorate(array(1)))->isEqualTo('integer(1)') 24 | ->string($decorator->decorate(array(1, 2)))->isEqualTo('integer(1), integer(2)') 25 | ->string($decorator->decorate(array(1.0)))->isEqualTo('float(1)') 26 | ->string($decorator->decorate(array(1.0, 2.1)))->isEqualTo('float(' . 1.0 . '), float(' . 2.1 . ')') 27 | ->string($decorator->decorate(array(true)))->isEqualTo('TRUE') 28 | ->string($decorator->decorate(array(false)))->isEqualTo('FALSE') 29 | ->string($decorator->decorate(array(false, true)))->isEqualTo('FALSE, TRUE') 30 | ->string($decorator->decorate(array(null)))->isEqualTo('NULL') 31 | ->string($decorator->decorate(array($this)))->isEqualTo('object(' . __CLASS__ . ')') 32 | ->if($stream = mock\stream::get()) 33 | ->and($stream->fopen = true) 34 | ->and($resource = fopen($stream, 'r')) 35 | ->and($dump = function() use ($resource) { ob_start(); var_dump($resource); return ob_get_clean(); }) 36 | ->then 37 | ->string($decorator->decorate(array($resource)))->isEqualTo($dump()) 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/units/classes/test/assertion/manager/exception.php: -------------------------------------------------------------------------------- 1 | testedClass->isSubClassOf('mageekguy\atoum\exceptions\runtime'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/test/engine.php: -------------------------------------------------------------------------------- 1 | testedClass->isAbstract(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/test/generator/exception.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\exceptions\runtime'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/units/classes/test/mock/generator.php: -------------------------------------------------------------------------------- 1 | testedClass->extends('mageekguy\atoum\mock\generator'); 17 | } 18 | 19 | public function test__construct() 20 | { 21 | $this 22 | ->if($generator = new testedClass($this)) 23 | ->then 24 | ->object($generator->getTest())->isIdenticalTo($this) 25 | ; 26 | } 27 | 28 | public function test__get() 29 | { 30 | $this 31 | ->if($generator = new testedClass($this)) 32 | ->and($generator->setTest($test = new \mock\mageekguy\atoum\test())) 33 | ->and($this->calling($test)->__get = function() {}) 34 | ->when($generator->{$property = uniqid()}) 35 | ->then 36 | ->mock($test)->call('__get')->withArguments($property)->once() 37 | ; 38 | } 39 | 40 | public function test__call() 41 | { 42 | $this 43 | ->if($generator = new testedClass($this)) 44 | ->and($generator->setTest($test = new \mock\mageekguy\atoum\test())) 45 | ->and($this->calling($test)->__call = function() {}) 46 | ->when($generator->{$property = uniqid()}()) 47 | ->then 48 | ->mock($test)->call('__call')->withArguments($property, array())->once() 49 | ; 50 | } 51 | 52 | public function testSetTest() 53 | { 54 | $this 55 | ->if($generator = new testedClass($this)) 56 | ->then 57 | ->object($generator->setTest($test = clone $this))->isIdenticalTo($generator) 58 | ->object($generator->getTest())->isIdenticalTo($test) 59 | ; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/units/classes/writer/decorators/eol.php: -------------------------------------------------------------------------------- 1 | testedClass->implements('mageekguy\atoum\writer\decorator'); 17 | } 18 | 19 | public function testDecorate() 20 | { 21 | $this 22 | ->if($decorator = new testedClass()) 23 | ->then 24 | ->string($decorator->decorate($message = uniqid()))->isEqualTo($message . PHP_EOL) 25 | ->string($decorator->decorate($message = uniqid() . PHP_EOL))->isEqualTo($message . PHP_EOL) 26 | ->string($decorator->decorate($message = ' ' . uniqid() . PHP_EOL . PHP_EOL))->isEqualTo($message . PHP_EOL) 27 | ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/units/classes/writer/decorators/rtrim.php: -------------------------------------------------------------------------------- 1 | if($decorator = new testedClass()) 18 | ->then 19 | ->string($decorator->decorate($message = uniqid()))->isEqualTo($message) 20 | ->string($decorator->decorate(($message = uniqid()) . PHP_EOL))->isEqualTo($message) 21 | ->string($decorator->decorate(' ' . ($message = uniqid()) . PHP_EOL . PHP_EOL))->isEqualTo(' ' . $message) 22 | ->string($decorator->decorate(PHP_EOL . ' ' . ($message = uniqid()) . PHP_EOL . PHP_EOL))->isEqualTo(PHP_EOL . ' ' . $message) 23 | ; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/units/classes/writer/decorators/trim.php: -------------------------------------------------------------------------------- 1 | if($decorator = new testedClass()) 18 | ->then 19 | ->string($decorator->decorate($message = uniqid()))->isEqualTo($message) 20 | ->string($decorator->decorate(($message = uniqid()) . PHP_EOL))->isEqualTo($message) 21 | ->string($decorator->decorate(' ' . ($message = uniqid()) . PHP_EOL . PHP_EOL))->isEqualTo($message) 22 | ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/units/classes/writers/std/err.php: -------------------------------------------------------------------------------- 1 | testedClass 18 | ->extends('mageekguy\atoum\writers\std') 19 | ->implements('mageekguy\atoum\report\writers\realtime') 20 | ->implements('mageekguy\atoum\report\writers\asynchronous') 21 | ; 22 | } 23 | 24 | public function test__construct() 25 | { 26 | $this 27 | ->if($stderr = new testedClass()) 28 | ->then 29 | ->object($stderr->getCli())->isEqualTo(new atoum\cli()) 30 | ->object($stderr->getAdapter())->isEqualTo(new atoum\adapter()) 31 | ->if($cli = new atoum\cli()) 32 | ->and($adapter = new atoum\test\adapter()) 33 | ->and($adapter->fopen = null) 34 | ->and($stderr = new testedClass($cli, $adapter)) 35 | ->then 36 | ->object($stderr->getCli())->isIdenticalTo($cli) 37 | ->object($stderr->getAdapter())->isIdenticalTo($adapter) 38 | ; 39 | } 40 | 41 | public function testWrite() 42 | { 43 | $this 44 | ->if($adapter = new atoum\test\adapter()) 45 | ->and($adapter->fopen = null) 46 | ->and($adapter->fwrite = null) 47 | ->and($stderr = new testedClass(null, $adapter)) 48 | ->then 49 | ->object($stderr->write($string = uniqid()))->isIdenticalTo($stderr) 50 | ->adapter($adapter)->call('fwrite')->withArguments(null, $string)->once() 51 | ->object($stderr->write($string = uniqid() . "\n"))->isIdenticalTo($stderr) 52 | ->adapter($adapter)->call('fwrite')->withArguments(null, $string)->once() 53 | ; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/units/runner.php: -------------------------------------------------------------------------------- 1 | addDirectory(__NAMESPACE__ . '\asserters', __DIR__ . '/asserters') 18 | ; 19 | --------------------------------------------------------------------------------