Giter VIP home page Giter VIP logo

atoum's Introduction

atoum's logo

atoum Package version Build Status Coverage Status Lint Gitter

PHP version atoum version
5.3 -> 5.6 1.x -> 3.x
7.2 -> 8.1 4.X -> 4.1
8.x 4.1 < 4.X (current)

A simple, modern and intuitive unit testing framework for PHP!

Just like SimpleTest or PHPUnit, atoum is a unit testing framework specific to the PHP language. However, it has been designed from the start with the following ideas in mind:

  • Can be implemented rapidly,
  • Simplify test development,
  • Allow for writing reliable, readable, and clear unit tests.

To accomplish that, it massively uses capabilities provided by PHP, to give the developer a whole new way of writing unit tests. Therefore, it can be installed and integrated into an existing project extremely easily, since it is only a single PHAR archive, which is the one and only entry point for the developer. Also, thanks to its fluent interface, it allows for writing unit tests in a fashion close to natural language. It also makes it easier to implement stubbing within tests, thanks to intelligent uses of anonymous functions and closures. atoum natively, and by default, performs the execution of each unit test within a separate PHP process, to warrant isolation. Of course, it can be used seamlessly for continuous integration, and given its design, it can be made to cope with specific needs extremely easily. atoum also accomplishes all of this without affecting performance, since it has been developed to boast a reduced memory footprint while allowing for hastened test execution. It can also generate unit test execution reports in the Xunit format, which makes it compatible with continuous integration tools such as Jenkins. atoum also generates code coverage reports, in order to make it possible to supervise unit tests. Finally, even though it is developed mainly on UNIX, it can also work on Windows.

Why atoum?

  • atoum is really easy to install: clone it from github, download its PHAR or simply use composer,
  • atoum provides a high level of security during test execution by isolating each test method in its own PHP process. Of course, this feature is available out of the box, no need to install any additional extension,
  • atoum runs tests in a parallelized environment making the suite run as fast as possible by taking advantage of today's multi-core CPUs,
  • atoum provides a full-featured set of natural and expressive assertions making tests as readable as possible. Here is an example:
<?php

$this
    ->integer(150)
        ->isGreaterThan(100)
        ->isLowerThanOrEqualTo(200)
;
  • atoum supports a BDD-like syntax with a lot of structural keywords:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($testedClass[] = $firstValue = uniqid())
    ->then
        ->sizeof($testedInstance)->isEqualTo(1)
        ->string($testedClass[0])->isEqualTo($firstValue)
;
  • atoum provides a dead simple, yet very powerful, mock engine:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($aMock = new \mock\foo\bar()) // here a mock of the class \foo\bar is created dynamically
    ->and($this->calling($aMock)->doOtherThing = true) // each call to doOtherThing() by the instance will return true
    ->and($testedInstance->setDependency($aMock))
    ->then
        ->boolean($testedInstance->doSomething())->isTrue()
        ->mock($aMock)
            ->call('doOtherThing')->withArguments($testedInstance)->once() // Asserts that the doOtherThing() method of $aMock was called once
;
  • atoum provides a clear API to assert on exceptions:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($aMock = new \mock\foo\bar()) // here a mock of the class \foo\bar is created dynamically
    ->and($this->calling($aMock)->doOtherThing->throw = $exception = new \exception()) // Call to doOtherThing() will throw an exception
    ->and($testedInstance->setDependency($aMock))
    ->then
        ->exception(function() use ($testedInstance) { $testedInstance->doSomething(); })
            ->isIdenticalTo($exception)
;
  • atoum also lets you mock native PHP functions. Again, this is available out of the box:
<?php

$this
    ->given($this->function->session_start = false)
    ->and($session = new testedClass())
    ->then
        ->exception(function () use ($session) { $session->start(); })
            ->isInstanceOf('project\namespace\exception')
            ->hasMessage('Unable to start session')
        ->function('session_start')->wasCalled()->once()
;
  • atoum is able to produce several reports like TAP, clover, xUnit to be easily integrated with Jenkins or any other continuous integration tool,
  • atoum supports data providers,
  • atoum tests support autorun: just include the atoum runner and launch your test using php path/to/test/file.php,
  • atoum's configuration file is exclusively written in PHP (no XML, YAML or any other format) giving you the best flexibility:
<?php

$script->addDefaultArguments('--test-it', '-ncc');

$runner->addTestsFromDirectory(__DIR__ . '/tests/units/classes');

$testGenerator = new atoum\atoum\test\generator();
$testGenerator
    ->setTestClassesDirectory(__DIR__ . '/tests/units/classes');
    ->setTestClassNamespace('atoum\atoum\tests\units');
    ->setTestedClassesDirectory(__DIR__ . '/classes');
    ->setTestedClassNamespace('atoum\atoum')
    ->setRunnerPath(__DIR__ . '/scripts/runner.php')
;

$runner->setTestGenerator($testGenerator);
  • atoum provides an automatic test template generator,
  • atoum provides a loop mode to easily retrigger failed tests,
  • atoum is full of other interesting features that you will discover over the time.

Prerequisites to use atoum

atoum absolutely requires PHP >= 5.6.0 or later to work. On UNIX, in order to check whether you have the right PHP version, you just need to run the following command in your terminal:

$ php -v | grep -oE 'php 5\.3\.(?:[3-9]|[1-9][0-9])|5\.[4-6]\.[0-9]+|[5-8]\.[0-9]+\.[0-9]+'

If PHP 5.6.x or equivalent gets displayed, then you have the right PHP version installed. Should you want to use atoum using its PHAR archive, you also need PHP to be able to access the phar module, which is normally available by default. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -m | grep -i phar

If Phar or equivalent gets displayed, then the module is properly installed. Generating reports in the Xunit format requires the xml module. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -m | grep -i xml

If Xml or equivalent gets displayed, then the module is properly installed. Should you wish to monitor the coverage rate of your code by the unit tests, the Xdebug 2.3 module will be required. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -v | grep -oi 'xdebug'

If Xdebug or equivalent gets displayed, then the module is properly installed.

A unit testing framework that can be made operational in 5 minutes!

Step 1: Install atoum

You just have to download its PHAR archive and store it where you wish, for example under /path/to/project/tests/atoum.phar. This PHAR archive contains the latest development version to pass the totality of atoum's unit tests. atoum's source code is also available via the GitHub repository. To check if atoum works correctly with your configuration, you can execute all its unit tests. To do that, you just need to run the following command in your terminal:

$ php atoum.phar --test-it

Step 2: Write your tests

Using your preferred text editor, create the file path/to/project/tests/units/helloWorld.php and add the following code:

<?php

namespace vendor\project\tests\units;

require_once 'path/to/atoum.phar';

include_once 'path/to/project/classes/helloWorld.php';

use atoum\atoum;
use vendor\project;

class helloWorld extends atoum\test
{
    public function testSay()
    {
        $helloWorld = new project\helloWorld();

        $this->string($helloWorld->say())->isEqualTo('Hello World!');
    }
}

Step 3: Run your test with the command line

Launch your terminal and run the following command:

$ php path/to/test/file[enter]

You should get the following result or something equivalent:

> atoum version XXX by Frédéric Hardy.
Error: Unattended exception: Tested class 'vendor\project\helloWorld' does not exist for test class 'vendor\project\tests\units\helloWorld'

Step 4: Write the class corresponding to your test

Using again your preferred text editor, create the file path/to/project/classes/helloWorld.php and add the following code:

<?php

namespace vendor\project;

class helloWorld
{
    public function say()
    {
        return 'Hello World!';
    }
}

Step 5: Run your test once more

In the same terminal, run the following command once again:

$ php path/to/test/file[enter]

You should get the following result, or something equivalent:

> atoum version 288 by Frédéric Hardy.
> Run vendor\project\tests\units\helloWorld...
[S___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.25 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.25 Mb.
> Code coverage value: 100.00%
> Running duration: 0.08 second.
> Success (1 test, 1 method, 2 assertions, 0 error, 0 exception)!

Step 6: Complete your tests and restart the cycle from Step 3

<?php

namespace vendor\project\tests\units;

require_once 'path/to/atoum.phar';

include_once 'path/to/project/classes/helloWorld.php';

use atoum\atoum;
use vendor\project;

class helloWorld extends atoum\test
{
    public function test__construct()
    {
        $helloWorld = new project\helloWorld();

        $this
            ->string($helloWorld->say())->isEqualTo('Hello!')
            ->string($helloWorld->say($name = 'Frédéric Hardy'))->isEqualTo('Hello ' . $name . '!')
        ;
    }
}

To go further

atoum's documentation is still being written. Any help to improve it will be appreciated. However, if you want to further explore immediately atoum's possibilities, we recommend:

  • Running in your terminal, either the command php atoum.phar -h, or the command php scripts/runner.php -h,
  • Exploring the contents of the configurations directory in atoum's source, as it contains configuration file samples,
  • Exploring the contents of the tests/unit/classes directory in atoum's source, as it contains all of the unit tests,
  • Read the (french) conference slides about it, available online,
  • Read the (french) wiki,
  • Join the discussion channel,
  • Ask questions by e-mail at the address support[AT]atoum(DOT)org.

Troubleshooting

atoum's PHAR archive seems to not be working

In this case, the first thing you will want to do is confirm whether you have the latest version of the archive. You just need to download it again. If it still doesn't work, run the following command in a terminal window:

$ php -n atoum.phar -v

If you get atoum's version number, then the problem is coming from your PHP configuration. In most cases, the cause would be within extensions, that might be incompatible with the PHAR format, or that would prevent executing PHAR archives as a security measure. The ioncube extension for instance seems incompatible with PHAR archives, and you must, therefore, deactivate it if you are using it, by commenting the following line out of your php.ini, by prefixing it with the ; character:

zend_extension = /path/to/ioncube_loader*.*

The suhosin extension prevents executing PHAR archives, therefore its default configuration must be modified in order to be able to use atoum, by adding the following line in your php.ini file:

suhosin.executor.include.whitelist="phar"

Finally, if running atoum causes the screen to display characters looking like ???%, this would be because the detect_unicode directive inside your php.ini file is set to 1. To fix the problem, you just need to set it to 0 by editing your php.ini file or by running atoum with the following command:

$ php -d detect_unicode=0 atoum.phar [options]

If these three operations do not allow atoum to work, we suggest you send an e-mail to the address support[AT]atoum(DOT)org, describing in detail your configuration and your problem. You can also ask for help from the atoum development staff on the discussion channel of the atoum repository..

Error: Constant __COMPILER_HALT_OFFSET__ already defined /path/to/atoum.phar

This error comes from the fact the atoum PHAR archive is included in more than one place within your code using include or require. To fix this problem, you just need to include the archive by using only include_once or require_once, in order to ensure it is not included several times.

APC seems not work with atoum

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code distributed under the form of a PHP extension. When testing classes that use APC, you may get some failure message showing that apc_fetch function is unable to retrieve a value. As all PHP extension, APC has some configuration options to enable it:

  • apc.enabled whether to enable or disable APC,
  • apc.enable_cli, whether to enable or disable APC for PHP CLI.

In order to use APC with atoum, you have to set apc.enabled and apc.enable_cli to 1, otherwise, it won't be enabled for the PHP CLI version, which is used by atoum.

Getting segfault when mocking objects

When using atoum and mocking objects, you will sometime get segfaults coming from PHP. These segfaults are caused by XDebug in version less than 2.1.0 which has problem handling reflection in some cases. To check the current version of XDebug, you can run php -v. To fix this issue, you have to update XDebug to the latest stable version. If you can't update XDebug on your system, you can still disable the extension to avoid getting segfaults. To be sure that XDebug has been successfully updated or disabled, you can run php -v. When you are done updating or disabling XDebug, run php atoum.phar --test-it to be sure that all the segfaults have gone and that atoum is working.


Roadmap

Looking for a roadmap?

Credits

atoum has been created by Frédéric Hardy. It is now led by a strong community of contributors. You can find them in the committer list or in the Contributors team.

License

atoum is released under the BSD-3-Clause License. See the bundled LICENSE file for details.

atoum's People

Contributors

adriencarbonne avatar agallou avatar cedcannes avatar cedric-anne avatar fdussert avatar fferriere avatar fvilpoix avatar gauthier avatar geraldcroes avatar grummfy avatar guillaumedievart avatar hywan avatar jeremyfreeagent avatar jubianchi avatar juliens avatar ludofleury avatar mageekguy avatar marmotz avatar mikaelrandy avatar remicollet avatar shavounet avatar stealth35 avatar stephpy avatar syrm avatar technosophos avatar tharkun avatar trasher avatar usul avatar villfa avatar vonglasow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atoum's Issues

Mocking Interface does'nt work as expected

So, the feature is not clear.
Atoum provide an handy way to instantiate a mock from an interface. But when I mock an Interface and then instantiate the mock, If any method expect the interface in it signature, php trigger an error.

<?php

namespace Foo;

interface BarInterface
{
}


class UseBar
{
    public function setBar(BarInterface $bar) 
    {
        //...
    }
}

// in the test
$this->mockClass('\Foo\BarInterface', '\Mock', 'BarMockedClass');
$mockBar = new \Mock\BarMockedClass();

$usebar = new UseBar();
$userbar_>setBar($mockBar); // Trigger error

Again, I understand the problem, (FQDN expected then mocked etc...) Yet when we instantiate a mock derived from an Interface, we expect the derived mock to implement the original interface.

die() in tested class still result in "Success"

If I die() in a tested method of a given class, the executed test still prints a "Success" message and returns "0".

> atoum version nightly-823-201111021458 by Frédéric Hardy 
> PHP path: /usr/bin/php5
> PHP version:
=> PHP 5.3.6-6~dotdeb.0 with Suhosin-Patch (cli) (built: Apr 17 2011 13:37:29)
=> Copyright (c) 1997-2011 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
> GivenClass...
[SSS.._______________________________________________________][3/5]
=> Test duration: 0.01 second.
=> Memory usage: 1.75 Mb.
> Total test duration: 0.01 second.
> Total test memory usage: 1.75 Mb.
> Running duration: 0.14 second.
Success (1 test, 5 methods, 30 assertions, 0 error, 0 exception) !

testing directory fail

Atoum version nightly-534-201106291627 by Frédéric Hardy (/Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar)

Hi,

$ php mageekguy.atoum.phar -d units/
Error: Constant COMPILER_HALT_OFFSET already defined /Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar 16

Display of the case in the output

In the ouput section at the end of the test's execution the case are not displayed.

The test where the output occured is diplay but not the case.

Remove call to ->assert in unit tests

Currently, for historical reasons, there are some calls to ->assert in unit tests, but since several months, this call is not mandatory.
So, all calls to ->assert must be removed from all unit test classes of atoum.
WARNING : Removing a call to ->assert can have a side effect on mocks and adapters, so adding a call to \mageekguy\atoum\test\adapter::resetCalls()or \mageekguy\atoum\mock\controller::resetCalls() must be mandatory.

foreach does not work if it was called in first

$this
  ->foreach(
    $array, 
    function() {
    }
  )
;

and

$this
  ->if($array = range(1, 10)
  ->then()
    ->foreach(
      $array, 
      function() {
      }
    )
;

does not work:

==> exception 'mageekguy\atoum\exceptions\logic\invalidArgument' with message 'Asserter 'foreach' does not exist' in mageekguy/atoum/classes/asserter/generator.php:97
==> Stack trace:
==> #0 mageekguy/atoum/classes/test/asserter/generator.php(76): mageekguy\atoum\asserter\generator->getAsserterInstance('foreach', Array)
==> #1 mageekguy/atoum/classes/test.php(214): mageekguy\atoum\test\asserter\generator->getAsserterInstance('foreach', Array)
==> #2 [internal function]: mageekguy\atoum\test->mageekguy\atoum\{closure}('foreach', Array)
==> #3 mageekguy/atoum/classes/test/assertion/manager.php(61): call_user_func_array(Object(Closure), Array)
==> #4 mageekguy/atoum/classes/test/assertion/manager.php(21): mageekguy\atoum\test\assertion\manager->invoke('foreach', Array)
==> #5 MyTest.php(261): mageekguy\atoum\test\assertion\manager->__call('foreach', Array)
==> #6 MyTest.php(261): mageekguy\atoum\test\assertion\manager->foreach(Array, Object(Closure))
==> #7 mageekguy/atoum/classes/test.php(657): MyTest->testMethod()
==> #8 -(1): mageekguy\atoum\test->runTestMethod('testMethod')
==> #9 {main}

On the other hand

$this
  ->object($object)
  ->foreach(
    $array, 
    function() {
    }
  )
;

works good

Use dependencies injector everywhere

Currently, the dependencies injector \mageekguy\atoum\dependenciesis using only in \mageekguy\atoum\test\adapter and \mageekguy\atoum\mock\stream\controller as proof of concept (see 1cc908b for more informations about it).
It must be used everywhere.

Unable to get PHP version

I finally decided few days ago to try creating few unit tests using atoum.

I had the following issue

Error: Unable to get PHP version from '/usr/bin/php5.3'

This appends in mageekguy\atoum\runner::setPathAndVersionInScore. The command to get php version works fine and return a 0 exit code

/usr/bin/php5.3 --version; echo $?;
PHP 5.3.6 (cli) (built: Apr 15 2011 08:10:12)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
0

The proc_get_status call returns

Array
(
[command] => /usr/bin/php5.3 --version
[pid] => 28021
[running] =>
[signaled] =>
[stopped] =>
[exitcode] => -1
[termsig] => 0
[stopsig] => 0
)

You can see why the script throws an exception, the exitcode is -1, but i don't have any idea why.

Any idea ?

Difference of the expected between 'isIdenticalTo' and 'isEqualTo' methods

When using the 'isEqualTo' method we got the difference between the expected value and the current value of what we're testing.

When using the 'isIdenticalTo' method we just got a message saying that the expected value is not identical to the current value.

Can we have the same behavior between this two methods?

atoum can't test itself

atoum can't test itself

(test with #f8014b2e0425c4c60602d25613b0d69e58276c48)

exemple :

php mageekguy.atoum.phar -d atoum/tests/units

Error: Constant mageekguy\atoum\directory already defined /Users/stealth35/Documents/atoum/constants.php 

and

php mageekguy.atoum.phar --testIt

PHP Fatal error:  include_once(): Cannot redeclare class mageekguy\atoum\tests\units\report\fields\runner\failures\cli in phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php on line 266
PHP Stack trace:
PHP   1. mageekguy\atoum\scripts\{closure}() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:0
PHP   2. mageekguy\atoum\scripts\phar\stub->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:334
PHP   3. mageekguy\atoum\scripts\runner->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/phar/stub.php:95
PHP   4. mageekguy\atoum\script->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:197
PHP   5. mageekguy\atoum\script\arguments\parser->parse() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script.php:116
PHP   6. mageekguy\atoum\script\arguments\parser->triggerHandlers() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:108
PHP   7. Closure->__invoke() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:170
PHP   8. mageekguy\atoum\scripts\{closure}() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:170
PHP   9. mageekguy\atoum\scripts\runner->testIt() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:192
PHP  10. mageekguy\atoum\scripts\runner->runDirectory() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:304
PHP  11. mageekguy\atoum\scripts\runner->runFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:287
PHP  12. mageekguy\atoum\scripts\phar\stub->includeFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:278
PHP  13. mageekguy\atoum\scripts\runner->includeFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/phar/stub.php:225

Fatal error: include_once(): Cannot redeclare class mageekguy\atoum\tests\units\report\fields\runner\failures\cli in phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php on line 266

Call Stack:
0.0499    2015336   1. mageekguy\atoum\scripts\{closure}() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:0
0.0500    2016464   2. mageekguy\atoum\scripts\phar\stub->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:334
0.0506    2028128   3. mageekguy\atoum\scripts\runner->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/phar/stub.php:95
0.0515    2049296   4. mageekguy\atoum\script->run() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:197
0.0515    2049376   5. mageekguy\atoum\script\arguments\parser->parse() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script.php:116
0.0518    2056592   6. mageekguy\atoum\script\arguments\parser->triggerHandlers() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:108
0.0518    2057752   7. Closure->__invoke() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:170
0.0518    2057832   8. mageekguy\atoum\scripts\{closure}() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/script/arguments/parser.php:170
0.0518    2057832   9. mageekguy\atoum\scripts\runner->testIt() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:192
0.0519    2058040  10. mageekguy\atoum\scripts\runner->runDirectory() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:304
0.3327   21246160  11. mageekguy\atoum\scripts\runner->runFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:287
0.3327   21246160  12. mageekguy\atoum\scripts\phar\stub->includeFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/runner.php:278
0.3327   21246160  13. mageekguy\atoum\scripts\runner->includeFile() phar:///Users/stealth35/Documents/mageekguy.atoum.phar/classes/scripts/phar/stub.php:225

How do I run atoum's tests?

I am interested in continuing to contribute patches to Atoum, but I need to make sure I am running Atoum's tests correctly.

What is the correct command for running atoum's own tests?

Thank you. I like Atoum a lot, and am using it in a very large project.

Setup continuous integration under Windows

Currently, the continuous integration of atoum is doing under FreeBSD and PHP 5.3.8.
It must be very interesting to setup an other continuous on a Windows server with same PHP version.

Fatal error on test::tearDown() call

Hi,

I got an issue with test::tearDown() method... It works very well but test.php seems to want to call a closure which doesn't exists on line 707.
Please, take a look at the console output below:

php units/Smak/Portfolio/Set.php -ncc
> atoum version nightly-822-201111021358 by Frédéric Hardy (phar:///.../net/eexit/Smak/tests/lib/atoum.phar)
> PHP path: /opt/local/bin/php
> PHP version:
=> PHP 5.3.8 (cli) (built: Oct 22 2011 22:30:22)
=> Copyright (c) 1997-2011 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
=>     with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans
> Smak\Portfolio\tests\units\Set...
[SSSSSSS_____________________________________________________][7/7]
Fatal error: Call to a member function callObservers() on a non-object in phar:///.../net/eexit/Smak/tests/lib/atoum.phar/classes/test.php on line 707

Call Stack:
    0.0233    2865536   1. mageekguy\atoum\scripts\{closure}() phar:///.../net/eexit/Smak/tests/lib/atoum.phar/classes/scripts/runner.php:0
    0.0233    2865536   2. mageekguy\atoum\scripts\runner->run(???) phar:///.../net/eexit/Smak/tests/lib/atoum.phar/classes/scripts/runner.php:263
    0.0381    4278960   3. mageekguy\atoum\runner->run(array(0), array(0), array(0), array(0), ???) phar:///.../net/eexit/Smak/tests/lib/atoum.phar/classes/scripts/runner.php:105
    0.0815    4608736   4. mageekguy\atoum\test->run(array(7), ???) phar:///.../net/eexit/Smak/tests/lib/atoum.phar/classes/runner.php:385

zsh: exit 255   php units/Smak/Portfolio/Set.php -ncc

Why is mageekguy\atoum\test abstract ?

Je voudrais pouvoir combiner Behat et les assertions d'Atoum.
Or, en héritant déjà de la classe BehatContext, je ne peux pas hériter de mageekguy\atoum\test, que je dois donc instancier et utiliser comme un attribut de ma classe. Ce n'est toutefois pas possible directement, puisque la classe est abstraite. Y a t-il une raison à cela ?

display proposition of assert when Atoum's exception is raised

like we have when we try to use wrong parameter in CLI

php mageekguy.atoum.phar --namespace
Error: Argument '--namespace' is unknown, did you mean '--namespaces' ?

We can have a proposition

Error: Assertion 'sting' is unknown, did you mean 'string' ?

See example

avonglasow@dev-alex:~/project/helloworld$ php tests/units/helloWorld.php 
> atoum version nightly-844-201112021413 by Frédéric Hardy (phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar)
> PHP path: /usr/bin/php5
> PHP version:
=> PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26)
=> Copyright (c) 1997-2009 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
=>     with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
=>     with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
> vendor\project\tests\units\helloWorld...
[E___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.00 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 0.59 second.
Failure (1 test, 1/1 method, 0 failure, 0 error, 1 exception) !
> There is 1 exception:
=> vendor\project\tests\units\helloWorld::testSay():
==> Exception throwed in file /home/avonglasow/project/helloworld/tests/units/helloWorld.php on line 19:
==> exception 'mageekguy\atoum\exceptions\logic\invalidArgument' with message 'Asserter 'mageekguy\atoum\asserters\sting' does not exist' in phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/asserter/generator.php:32
==> Stack trace:
==> #0 phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/asserter/generator.php(65): mageekguy\atoum\asserter\generator->__get('sting')
==> #1 /home/avonglasow/project/helloworld/tests/units/helloWorld.php(19): mageekguy\atoum\asserter\generator->__call('sting', Array)
==> #2 /home/avonglasow/project/helloworld/tests/units/helloWorld.php(19): mageekguy\atoum\asserter\generator->sting('Hello World!')
==> #3 phar:///home/avonglasow/project/helloworld/tests/mageekguy.atoum.phar/classes/test.php(539): vendor\project\tests\units\helloWorld->testSay()
==> #4 -(1): mageekguy\atoum\test->runTestMethod('testSay')
==> #5 {main}
Error: Assertion 'sting' is unknown, did you mean 'string' ?

Atoum under Windows

Hi,

I tried to execute Atoum under Windows. Runner doesn't work because it uses the PHP_BINDIR predefined constant that is always equals to "c:\php "under Windows. I copied my PHP executable under this directory but there are side effects after to get the PHP version for instance. There is a way to avoid using of PHP_BIN_DIR ?
Best regards,

Cédric

Atoum tests failed with php 5.4.0beta1

$ php -v
PHP 5.4.0beta1-dev (cli) (built: Sep 13 2011 08:42:11)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2011 Zend Technologies

Test failed

Failure (111 tests, 787 methods, 1 failure, 0 error, 2 exceptions) !

There is 1 failure:
=> mageekguy\atoum\tests\units\scripts\phar\generator::testRun():
In file phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php on line 516, mageekguy\atoum\asserters\exception::isInstanceOf() failed: object(LogicException) is not an instance of mageekguy\atoum\exceptions\logic
There are 2 exceptions:
=> mageekguy\atoum\tests\units\scripts\phar\generator::testSetFileIteratorInjector():
==> Exception throwed in file phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php on line 323:
==> exception 'LogicException' with message 'In the constructor of mock\recursiveDirectoryIterator, parent::__construct() must be called and its exceptions cannot be cleared' in phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php:323
==> Stack trace:
==> #0 phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php(323): mock\recursiveDirectoryIterator->internal_construction_wrapper('4e945a9a84b59')
==> #1 phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/classes/test.php(490): mageekguy\atoum\tests\units\scripts\phar\generator->testSetFileIteratorInjector()
==> #2 -(1): mageekguy\atoum\test->runTestMethod('testSetFileIter...')
==> #3 {main}
=> mageekguy\atoum\tests\units\scripts\phar\generator::testSetPharInjector():
==> Exception throwed in file phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php on line 282:
==> exception 'LogicException' with message 'In the constructor of mock\phar, parent::__construct() must be called and its exceptions cannot be cleared' in phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php:282
==> Stack trace:
==> #0 phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/tests/units/classes/scripts/phar/generator.php(282): mock\phar->internal_construction_wrapper('4e945a9a98608')
==> #1 phar:///media/data/dev/friendsdiff/vendor/mageekguy.atoum.phar/classes/test.php(490): mageekguy\atoum\tests\units\scripts\phar\generator->testSetPharInjector()
==> #2 -(1): mageekguy\atoum\test->runTestMethod('testSetPharInje...')
==> #3 {main}

file_put_contents(/tmp/atoum.score): failed to open stream: Permission denied

If many users launch tests on a single machine, atoum bug.

One user create a file /tmp/atoum.score with his uid/gid.
The second one can't launch atoum:

Warning: file_put_contents(/tmp/atoum.score): failed to open stream: Permission denied in /var/www/html/lib/atoum/src/classes/adapter.php on line 18

Call Stack:
    0.0104    2082536   1. mageekguy\atoum\scripts\{closure}() /var/www/html/lib/atoum/src/classes/scripts/runner.php:0
    0.0104    2082536   2. mageekguy\atoum\scripts\runner->run() /var/www/html/lib/atoum/src/classes/scripts/runner.php:245
    0.1401    4523008   3. mageekguy\atoum\scripts\runner->saveScore() /var/www/html/lib/atoum/src/classes/scripts/runner.php:123
    0.1401    4525464   4. mageekguy\atoum\adapter->file_put_contents() /var/www/html/lib/atoum/src/classes/scripts/runner.php:611
    0.1401    4525992   5. mageekguy\atoum\adapter->__call() /var/www/html/lib/atoum/src/classes/scripts/runner.php:611
    0.1401    4525992   6. mageekguy\atoum\adapter->invoke() /var/www/html/lib/atoum/src/classes/adapter.php:13
    0.1401    4526040   7. call_user_func_array() /var/www/html/lib/atoum/src/classes/adapter.php:18

Error: Unable to save score in '/tmp/atoum.score'

Add a pattern support for directory CLI argument

It would be very handy to support a pattern like bin/atoum -d src/*/Tests/Units
I think It could be done by 2 ways: changing the CLI acceptance (simplest) or allowing the injection of a custom iterator filter (could be more permissive).

What's do you think about this ?

Rapport xunit incomplet lorsqu'un test échoue

Je fais en ce moment des tests d'intégration continue sur mes projets perso avec Jenkins et j'ai voulu volontairement faire échouer un test (modifiant la valeur d'un retour attendu) et je me suis rendu compte que dans le rapport généré, la classe testée disparait complètement du résultat :

Résultat attendu:

<?xml version="1.0" encoding="UTF-8"?>
    <testsuites name="atoum testsuite">
    <testsuite name="Collection" package="Smak\Portfolio\tests\units" tests="10" failures="0" errors="0" time="0.72568535804749">
        // noeuds testcase
    </testsuite>
    <testsuite name="Photo" package="Smak\Portfolio\tests\units" tests="5" failures="0" errors="0" time="0.24299097061157">
        // noeuds testcase
    </testsuite>
    <testsuite name="Set" package="Smak\Portfolio\tests\units" tests="14" failures="0" errors="0" time="0.79837799072266">
        // noeuds testcase
    </testsuite>
</testsuites>

Résultat reçu avec un test volontairement faux dans la classe Set:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="atoum testsuite">
    <testsuite name="Collection" package="Smak\Portfolio\tests\units" tests="10" failures="0" errors="0" time="1.2468225955963">
        // noeuds testcase
    </testsuite>
    <testsuite name="Photo" package="Smak\Portfolio\tests\units" tests="5" failures="0" errors="0" time="0.12544465065002">
        // noeuds testcase
    </testsuite>
</testsuites>

On voit bien ici que le la suite de test complète est zappée du coup, ça fausse le résultat du rapport puisque finalement, aucun test n'est marqué comme échoué.

Unable to test method which use func_get_args() in mocked class

I have a class with a method without parameter in declaration but which use func_get_args():

class MyClass {
    public function myMethod() {
        $args = func_get_args();
        // ...
    }
}

In my tests, i create a mock of this class and want to test this method. But the generate code is:

class MyClass extends atoum\test {
    public function testMyMethod() {
        $this->mockTestedClass();
        $myClass = new \mock\MyClass;

        $this->assert()
            ->string($myClass->myMethod('foo'))
                ->isEqualTo('bar')
    }
}

This test fail because myMethod never receive parameter.

In mageekguy\atoum\mock\generator::getMockedClassCode(), here is the generated code:

// ...snip...
public function myMethod()
    {
        if (isset($this->getMockController()->myMethod) === true)
        {
            return $this->mockController->invoke('myMethod', array());
        }
        else
        {
            $this->getMockController()->addCall('myMethod', array());
            return parent::myMethod();
        }
    }
// ...snip...

mageekguy.atoum.phar --testIt produces one error

Hi,
i've just run the tests and got just one error at the end :

Running duration: 235.81 seconds.
Failure (131 tests, 959/959 methods, 0 failure, 1 error, 0 exception) !
There is 1 error:
=> mageekguy\atoum\tests\units\factory::testBuild():
==> Error E_WARNING in phar:///home/foxmask/mageekguy.atoum.phar/1/tests/units/classes/factory.php on line 50, generated by file phar:///home/foxmask/mageekguy.atoum.phar/1/classes/factory.php on line 24: Unknown class passed as parameter

regards

Unable to use an abstract class without require

As mentioned in the wiki here, I wanted to change the default namespace with an abstract class.
I use an autoloader and don't want to include atoum in all my test files. Yet atoum is unable to launch test because he can't find the abstract class extended by my final.

I didn't take too much time to make some reverse, yet it appear that the atoum process do not rely on the autoloader at start.

Allowing the user to change default mock generator behaviour

By default, a mock has the same interface and the same behavior than it's model, that is to say if foo::bar() return true, \mock\foo::bar() return true too.
It must be interesting to allow the user to change this, i.e. a call to \mock\foo::bar() return by default null instead of true.
The idea is to define \mageekguy\atoum\mock\generator::mockAllMethods() and \mageekguy\atoum\mock\generator::notMockAllMethods() to do that :

<?php

public function testSomething()
{
   /* ... */
   $this->mockGenerator->mockAllMethods();
   $mock = new \mock\foo();
   var_dump($mock->bar(); // NULL

   $this->mockGenerator->notMockAllMethods();
   $otherMock = new \mock\foo();
   var_dump($otherMock->bar(); // TRUE
   /* ... */
} 

Atoum tests blocked on windows

php mageekguy.atoum.phar --testIt

atoum version nightly-962-201201232248 by Fr├®d├®ric Hardy (phar://c:/xxxxxxxxxxxxxx/vendor/mageekguy.atoum.phar/1)
PHP path: c:\UwAmp\bin\php\php-5.3.5\php.exe
PHP version:
=> PHP 5.3.5 (cli) (built: Jan 6 2011 17:54:09)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
mageekguy\atoum\tests\units\adapter...
[.][0/1]
[S
][1/1]
=> Test duration: 0.03 second.
=> Memory usage: 0.25 Mb.
mageekguy\atoum\tests\units\annotations\extractor...
[......][0/6]
[S.....
][1/6]
[SS....][2/6]
[SSS...
][3/6]
[SSSS..][4/6]
[SSSSS.
][5/6]
[SSSSSS______________________________________________________][6/6]
=> Test duration: 0.31 second.
=> Memory usage: 1.75 Mb.
mageekguy\atoum\tests\units\asserter\generator...
[.........___________________________________________________][0/9]^C

Can't run phar on windows ?

php mageekguy.atoum.phar --testIt
Error: Unable to find PHP executable

php -v
PHP 5.3.5 (cli) (built: Jan 6 2011 17:54:09)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Same thing with the php :
php atoum/scripts/runner.php
Error: Unable to find PHP executable

testing atoum phar... fail

Atoum version nightly-534-201106291627 by Frédéric Hardy (/Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar)

Hi,

I run the following command :
$ php mageekguy.atoum.phar --testIt

bugs :

=> Test duration: 0.03 second.
=> Memory usage: 0.50 Mb.

mageekguy\atoum\tests\units\template\data:
[SSSSSSSSSSSSSSSSSSS_________________________________________][19/19]
=> Test duration: 0.18 second.
=> Memory usage: 6.00 Mb.
PHP Fatal error: Cannot redeclare class mageekguy\atoum\report\fields\test\run in phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/report/fields/test/run.php on line 9
PHP Stack trace:
PHP 1. mageekguy\atoum\scripts{closure}() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:0
PHP 2. mageekguy\atoum\scripts\phar\stub->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:292
PHP 3. mageekguy\atoum\scripts\runner->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/phar/stub.php:95
PHP 4. mageekguy\atoum\runner->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:223
PHP 5. mageekguy\atoum\test->__construct() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/runner.php:311
PHP 6. mageekguy\atoum\adapter->class_exists() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/test.php:69
PHP 7. mageekguy\atoum\adapter->__call() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:69
PHP 8. mageekguy\atoum\adapter->invoke() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:11
PHP 9. call_user_func_array() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:16
PHP 10. mageekguy\atoum\autoloader::getClass() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/autoloader.php:0
PHP 11. require() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/autoloader.php:59

Fatal error: Cannot redeclare class mageekguy\atoum\report\fields\test\run in phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/report/fields/test/run.php on line 9

Call Stack:
0.0147 1815760 1. mageekguy\atoum\scripts{closure}() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:0
0.0147 1816616 2. mageekguy\atoum\scripts\phar\stub->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:292
0.0150 1824872 3. mageekguy\atoum\scripts\runner->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/phar/stub.php:95
0.1654 24210184 4. mageekguy\atoum\runner->run() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/scripts/runner.php:223
69.5415 33079160 5. mageekguy\atoum\test->__construct() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/runner.php:311
69.5416 33084152 6. mageekguy\atoum\adapter->class_exists() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/test.php:69
69.5416 33084504 7. mageekguy\atoum\adapter->__call() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:69
69.5416 33084504 8. mageekguy\atoum\adapter->invoke() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:11
69.5416 33084552 9. call_user_func_array() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/adapter.php:16
69.5417 33085360 10. mageekguy\atoum\autoloader::getClass() phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/autoloader.php:0
69.5418 33086104 11. require('phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/report/fields/test/run.php') phar:///Users/euskadi31/php/testunit/tests/mageekguy.atoum.phar/classes/autoloader.php:59

Bug with atoum mock

When I try to mock a class which inherit from another class, the parent constructor is always called.

<?php

class A
{
    public function __construct()
    {
        echo 'foo';
    }
}

class B extends A
{
}

// When mocking B, A::__construct is called, even if I define an empty B::__construct() this way:
$mockController = new \mageekguy\atoum\mock\controller();
$mockController->__construct = function() {};
$mockController->controlNextNewMock();

$this->mock('B','\\Mock', 'MockB');
new \Mock\MockB();

Is it a Bug ? Did I miss something ?

Atoum blocked

Bonjour.

Atoum se bloque lorsqu'on appelle une fonction inexistante sur un objet d'une de ses classes. Par exemple, avec le code ci-dessous :

<?php
namespace essai\test\unit;

require_once 'Essai.php';
require_once 'atoum.phar';

class Essai extends \mageekguy\atoum\test
{
    public function testSimple()
    {
        // Ceci :
        $this->completyWrongFunctionName();

        // Ceci également :
        $this->assert->completyStupidFunctionName();
    }
}
?>

La sortie est la suivante :

php test/atoum.phar -f test/Essai.php -n

PHP path: XXX\WampServer\bin\php\php5.3.8\php.exe
PHP version:
=> PHP 5.3.8 (cli) (built: Sep 16 2011 21:28:32)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
essai\test\unit\Essai...
[.___________________________________________________________][0/1]

Et le script ne s'arrête pas.
La même chose se produit lors de l'utilisation de --testIt.

PHP 5.3.8
Windows 7

Add comments for magic properties/methods

For example, in mageekguy\atoum\test, add following lines to easily use "virtual method" in IDE with auto completion. (Like Doctrine 1 base model generator)

/**

  • @Property mageekguy\atoum\asserter\generator $assert
  • @method mageekguy\atoum\asserter\generator assert()
    */
    abstract class test implements observable, adapter\aggregator, \countable
    {
    ...
    }

Removing \mageekguy in namespace

Currently, the top level namespace of atoum is \mageekguy\atoum.
It seems that is not a good thing for the project that my nickname is using in it, so \mageekguy\atoum must be replaced by \atoum.

Problem cloning repo

I get this message when I try to clone atoum :

patrickl@mymachine:~/workspace$ git clone https://github.com/mageekguy/atoum.git
Cloning into atoum...
warning: remote HEAD refers to nonexistent ref, unable to checkout.

The repo itself is created, but when I ask what branch I can use :

patrickl@mymachine:/workspace$ cd atoum/
patrickl@mymachine:
/workspace/atoum$ git branch
patrickl@mymachine:~/workspace/atoum$ (cursor)

I really get nothing, and a small du -sh returns this :
patrickl@PXPLY2758-ubuntu:~/workspace/atoum$ du -sh
228K .

Which means, if I'm not mistaken, that the repo is quite... Small :)

Of course, this does not disable me from using atoum (I just use the PHAR archive you provide in the README, many thanks, by the way), but I cannot use your last updates XD

How to do conditionnal assertions ?

Hello as a beginner Atoum user I'm confronted to a problem. I want to make different assertions depending of the return value of a method.

Here is a quick example :

class Armaggedon
{
        private EndDate;

    public function __construct($aParam)
    { 
        $this->EndDate= $aParam; 
    } 
    public function apocalypse()
    {
        if($this->EndDate==2012)
            return true;
                else
                return false;
    }
}

I want to test if the return value is a boolean, but also if it's true when value of EndDate is 2012 and false in other case.

How can I implement the test class of Armaggedon ?

Thanks for your future answers.

Case sensivity for mocked methods

In the mocked class of \XSLTProcessor i wrote transformToXML instead of transformToXml and i've got the 'Method 'mock\XSLTProcessor::transformToXML()' does not exist' message.

Is there a way to avoid this behaviour knowing that with php calling the mehod transformToXML will work?

Atoum & APC

It seems like there is an issue when testing classes that use APC to store some values in cache : the APC extension's functions mixed apc_fetch ( mixed $key [, bool &$success ] ) is not able to retrieve values previously stored, constantly returning bool(false).

Here is the code I use to reproduce this behavior : https://gist.github.com/465cd0b192cb570db779

Bug when rename/delete a test file with loop mode

  • i run tests with loop mode
  • after results (Success), i rename or delete a test file
  • i type [ENTER] to re-run tests:
    Error: Unable to add test file '/project/Tests/Units/MyDeletedOrRenamedTest.php'

Erreur extension Xdebug : Maximum function nesting level of '100' reached

Bonjour, actuellement en pleine implémentation de tests unitaires avec atoum je rencontre quelques sur certaines classes, d'après mes recherches ce serait lié à l'extension Xdebug, voici ci-dessous ma trace d'exécution.

> PHP path: /usr/local/php/bin/php
> PHP version:
=> PHP 5.4.3 (cli) (built: Jun  4 2012 16:48:31) (DEBUG)
=> Copyright (c) 1997-2012 The PHP Group
=> Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
=>     with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans
> tests\units\cgLdap...
[U___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.00 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 2.41 seconds.
Failure (1 test, 0/1 method, 0 failure, 1 error, 0 exception) !
> There is 1 error:
=> tests\units\cgLdap::testGetUtil():
==> Error FATAL ERROR in /Bureau/ProdeliaTests/outilsTests/tests_unit/tests/tuCgLdap.class.php on unknown line, generated by file /                                                                                                          Bureau/ProdeliaTests/gene/include/php/cgErreurs.class.php on line 576:
Maximum function nesting level of '100' reached, aborting!
> There is 1 uncompleted method:
=> tests\units\cgLdap::testGetUtil() with exit code 255:
==> output(4) ""
[root@LampP-caenEMO tests]#

J'ai donc dans un premier temps augmenté drastiquement le "maximum function nesting level" dont la valeur par défaut est à 100 dans mon fichier php.ini, voici ma config de xdebug dans le fichier php.ini :

[xdebug]
zend_extension=/usr/local/php/lib/php/extensions/debug-non-zts-20100525/xdebug.so


xdebug.max_nesting_level=512

Néanmoins à l'exécution le problème persiste, j'atteins quand même la limite des 512, voici ma trace :

> PHP path: /usr/local/php/bin/php
> PHP version:
=> PHP 5.4.3 (cli) (built: Jun  4 2012 16:48:31) (DEBUG)
=> Copyright (c) 1997-2012 The PHP Group
=> Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
=>     with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans
> tests\units\cgLdap...
[U___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.00 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 27.22 seconds.
Failure (1 test, 0/1 method, 0 failure, 1 error, 0 exception) !
> There is 1 error:
=> tests\units\cgLdap::testGetUtil():
==> Error FATAL ERROR in /Bureau/ProdeliaTests/outilsTests/tests_unit/tests/tuCgLdap.class.php on unknown line, generated by file /Bureau/ProdeliaTests/gene/include/php/cgErreurs.class.php on line 576:
Maximum function nesting level of '512' reached, aborting!
> There is 1 uncompleted method:
=> tests\units\cgLdap::testGetUtil() with exit code 255:
==> output(4) ""
[root@LampP-caenEMO tests]#

En désactivant l'extension xdebug, le test m'indique une sorte de débordement mémoire :

> PHP path: /usr/local/php/bin/php
> PHP version:
=> PHP 5.4.3 (cli) (built: Jun  4 2012 16:48:31) (DEBUG)
=> Copyright (c) 1997-2012 The PHP Group
=> Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
> tests\units\cgLdap...
[U___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.00 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 50.71 seconds.
Failure (1 test, 0/1 method, 0 failure, 1 error, 0 exception) !
> There is 1 error:
=> tests\units\cgLdap::testGetUtil():
==> Error FATAL ERROR in /Bureau/ProdeliaTests/outilsTests/tests_unit/tests/tuCgLdap.class.php on unknown line, generated by file /Bureau/ProdeliaTests/gene/include/php/cgErreurs.class.php on line 581:
Allowed memory size of 100663296 bytes exhausted at /usr/local/src/php-5.4.3/Zend/zend_operators.c:1267 (tried to allocate 82918 bytes)
> There is 1 uncompleted method:
=> tests\units\cgLdap::testGetUtil() with exit code 255:
==> output(4) ""
[root@LampP-caenEMO tests]#

Auriez vous une idée de l'origine de mon problème? Merci d'avance pour votre aide précieuse :)

Adding some methods in asserters

Hi every one,

I 'm not sure it is the right place to propose new functionnalities but let's go on.

I think it would be nice to add some methods in asserters to help developpers so they can write quicker tests.

I've noticed that the integer asserter only implements the following methods.

  • isZero
  • isEqualTo
  • isGreaterThan

It would be nice to extend this asserter with the following methods. (and it isn't that much to do)

  • isLowerThan
  • isGreaterEqualThan
  • isLowerEqualThan

I was writing some tests last week and i had to check whether or not a string was a md5 string or not. I did it using match method but i think it could be quicker if the string asserter already had this method.

What do you think about it ?

Atoum under Windows

In order to complete #84 under Windows, here are some additional tests :

PHP 5.3.8

PHP 5.3.8 (cli) (built: Sep 16 2011 21:28:32)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

Failure (141 tests, 1026/1026 methods, 1 failure, 0 error, 0 exception) !
There is 1 failure:
=> mageekguy\atoum\tests\units\mock\stream::testGetSubStream():
In file phar://XXX/tests/units/classes/mock/stream.php on line 80, mageekguy\atoum\asserters\castToString::match() failed: string(35) 'atoum://4fe9b76d7485d\4fe9b76d74fd2' does not match #^atoum://4fe9b76d7485d[^]+$#

PHP 5.3.6

PHP 5.3.6 (cli) (built: Mar 17 2011 10:48:37)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

Failure (141 tests, 1025/1026 methods, 1 failure, 0 error, 0 exception) !
There is 1 failure:
=> mageekguy\atoum\tests\units\mock\stream::testGetSubStream():
In file phar://XXX/tests/units/classes/mock/stream.php on line 80, mageekguy\atoum\asserters\castToString::match() failed: string(35) 'atoum://4fe9c84dba468\4fe9c84dba6f3' does not match #^atoum://4fe9c84dba468[^]+$#
There is 1 uncompleted method:
=> mageekguy\atoum\tests\units\mock\generator::testGenerate() with exit code -1073741819:
==> output(0) ""

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.