1. Go to this page and download the library: Download atoum/atoum-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
atoum / atoum-bundle example snippets
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
//.....
$bundles[] = new atoum\AtoumBundle\AtoumAtoumBundle();
}
// src/Acme/MyBundle/Tests/Units/Entity/HelloWorld.php
namespace Acme\MyBundle\Tests\Units\Entity;
// if you don't use a bootstrap file, (or composer) you need to /../../../../../vendor/mageekguy.atoum.phar';
use atoum\AtoumBundle\Test\Units;
class helloWorld extends Units\Test
{
}
toum\AtoumBundle\Test\Units;
class helloWorld extends Units\WebTestCase
{
public function testMyTralala()
{
$client = $this->createClient();
}
}
namespace My\Bundle\FoobarBundle\Tests\Units\Command;
use atoum\AtoumBundle\Test\Units as AtoumBundle;
use mageekguy\atoum;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
// Assuming that this command will display "Success" if succes, and returns a boolean
use My\Bundle\FoobarBundle\Command\FoobarCommand as Base;
class FoobarCommand extends AtoumBundle\CommandTestCase
{
public function testExecute()
{
$this
->given(
$command = new Base()
)
->if($commandTester = $this->createCommandTester($command))
->then
->boolean($commandTester->execute())
->isTrue()
->string($commandTester->getDisplay())
->contains("Success")
;
}
}
namespace vendor\FooBundle\Tests\Controller;
use atoum\AtoumBundle\Test\Units\WebTestCase;
use atoum\AtoumBundle\Test\Controller\ControllerTest;
class BarController extends ControllerTest
{
public function testGet()
{
$this
->request(array('debug' => true))
->GET('/demo/' . uniqid())
->hasStatus(404)
->hasCharset('UTF-8')
->hasVersion('1.1')
->POST('/demo/contact')
->hasStatus(200)
->hasHeader('Content-Type', 'text/html; charset=UTF-8')
->crawler
->hasElement('#contact_form')
->hasChild('input')->exactly(3)->end()
->hasChild('input')
->withAttribute('type', 'email')
->withAttribute('name', 'contact[email]')
->end()
->hasChild('input[type=submit]')
->withAttribute('value', 'Send')
->end()
->hasChild('textarea')->end()
->end()
->hasElement('li')
->withContent('The CSRF token is invalid. Please try to resubmit the form.')
->exactly(1)
->end()
->hasElement('title')
->hasNoChild()
->end()
->hasElement('meta')
->hasNoContent()
->end()
->hasElement('link')
->isEmpty()
->end()
;
}
}
namespace Acme\DemoBundle\Tests\Form;
use Acme\DemoBundle\Entity\TestEntity;
use atoum\AtoumBundle\Test\Form;
use Acme\DemoBundle\Form\TestEntityType as MyTypeToTest;
class TestEntityType extends Form\FormTestCase{
public function testToutCourt()
{
$formData = array(
'texte1' => 'test 1',
'texte2' => 'test 2',
);
$type = new MyTypeToTest();
$form = $this->factory->create($type);
$object = new TestEntity();
$object->fromArray($formData);
// submit the data to the form directly
$form->submit($formData);
$this->boolean($form->isSynchronized())->isTrue();
$this->variable($object)->isEqualTo($form->getData());
$view = $form->createView();
$children = $view->children;
foreach (array_keys($formData) as $key) {
$this->array($formData)->hasKey($key);
}
}
}
public function testMyAmazingFeature()
{
//.....
$randomName = $this->faker->name;
$dateTimeBetweenYesterdayAndNow = $this->faker->dateTimeBetween('-1 day', 'now');
//.....
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.