1. Go to this page and download the library: Download lastzero/test-tools 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/ */
lastzero / test-tools example snippets
use TestTools\TestCase\UnitTestCase;
class FooTest extends UnitTestCase
{
protected $foo;
public function setUp()
{
$this->foo = $this->get('foo');
}
public function testBar()
{
$result = $this->foo->bar('Pi', 2);
$this->assertEquals(3.14, $result);
}
}
use TestTools\Fixture\SelfInitializingFixtureTrait;
class Foo extends SomeBaseClass
{
use SelfInitializingFixtureTrait;
public function bar($name, $type, array $baz = array())
{
return $this->callWithFixtures('bar', func_get_args());
}
}
use TestTools\TestCase\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FooControllerTest extends WebTestCase
{
protected function configureFixtures(ContainerInterface $container)
{
// Service instance must provide a useFixtures() method for this to work
$container->get('db')->useFixtures($this->getFixturePath());
}
public function testGetBar()
{
$response = $this->getRequest('/foo/bar/Pi', array('precision' => 2));
$this->assertEquals(3.14, $response->getContent());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.