Skip to content

Instantly share code, notes, and snippets.

@jubianchi
Created July 30, 2012 20:30
Show Gist options
  • Save jubianchi/3209900 to your computer and use it in GitHub Desktop.
Save jubianchi/3209900 to your computer and use it in GitHub Desktop.
atoum test
<?php
use \mageekguy\atoum;
$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);
$xunit = new atoum\reports\asynchronous\xunit();
$writer = new atoum\writers\file('atoum.xml');
$xunit->addWriter($writer);
$runner->addReport($cliReport);
$runner->addReport($xunit);
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="atoum testsuite">
<testsuite name="computer" package="tests\unit" tests="1" failures="0" errors="0" time="0.00084114074707031">
<testcase name="testCompute" time="0.00084114074707031" file="/Users/jubianchi/repositories/fake/tests/unit/computer.php" classname="tests\unit\computer"/>
</testsuite>
</testsuites>
<?php
class computer {
public function compute($a, $b) {
return $a + $b;
}
}
<?php
namespace tests\unit;
use mageekguy\atoum\test;
use computer as testedClass;
require_once __DIR__ . '/../../atoum/classes/test.php';
require_once __DIR__ . '/../../computer.php';
class computer extends test {
public function testCompute() {
$this
->if($object = new testedClass())
->then
->integer($object->compute(1, 2))->isEqualTo(3);
}
}
@jubianchi
Copy link
Author

mageekguy/atoum@8ff37c4

$ php atoum/scripts/runner.php 
> PHP path: /usr/bin/php
> PHP version:
=> PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20)
=> Copyright (c) 1997-2012 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
> Total test duration: 0.00 second.
> Total test memory usage: 0.00 Mb.
> Running duration: 0.04 second.
Success (0 test, 0/0 method, 0 assertion, 0 error, 0 exception) !

$ php atoum/scripts/runner.php -d tests/unit
> PHP path: /usr/bin/php
> PHP version:
=> PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20)
=> Copyright (c) 1997-2012 The PHP Group
=> Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
> tests\unit\computer...
[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.
> Running duration: 0.09 second.
Success (1 test, 1/1 method, 2 assertions, 0 error, 0 exception) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment