Tester – problém s routama?

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Jack06
Člen | 168
+
0
-
<?php

namespace Test;

require __DIR__ . '/../../app/bootstrap.php';

class TheaterRepositoryTest extends \Tester\TestCase
{

    /** @var \Nette\DI\Container */
    private $container;

    /** @var \TheaterModule\TheaterRepository */
    private $repository;

    public function __construct(\Nette\DI\Container $container)
    {
	$this->container = $container;
    }

    protected function setUp()
    {
	$this->repository = $this->container->getByType('TheaterModule\IDivadlo');
    }

    public function testCreate()
    {

	$theaterOne = array(
	    'id' => 1,
	    'name' => 'Divadlo jedna',
	    'capacity' => 10,
	    'address' => 'Adresa jedna'
	);

	$theaterTwo = array(
	    'id' => 2,
	    'name' => 'Divadlo dva',
	    'capacity' => 100,
	    'address' => 'Adresa dva'
	);

	$theaterThree = array(
	    'id' => 3,
	    'name' => 'Divadlo tři',
	    'capacity' => 1000,
	    'address' => 'Adresa tři'
	);

	$insertOne = $this->repository->create($theaterOne);
	\Tester\Assert::same('Divadlo jedna', $insertOne->name);

	$insertTwo = $this->repository->create($theaterTwo);
	\Tester\Assert::notSame('Divadlo jedna', $insertTwo->name);

	$insertThree = $this->repository->create($theaterThree);
	\Tester\Assert::same('Divadlo tři', $insertThree->name);
    }

    public function testUpdate()
    {
	$theaterOne = array(
	    'name' => 'Divadlo jedna uprava',
	    'capacity' => 10,
	    'address' => 'Adresa jedna'
	);

	$updated = $this->repository->update(1, $theaterOne);
	\Tester\Assert::equal(1, $updated);

	$result = $this->repository->findById(1);
	\Tester\Assert::same('Divadlo jedna uprava', $result->name);
    }

    public function testDelete()
    {
	$countBefore = $this->repository->findAll()->count('id');
	\Tester\Assert::equal(3, $countBefore);

	$delete = $this->repository->delete(1);
	\Tester\Assert::equal(1, $delete);

	$countAfter = $this->repository->findAll()->count('id');
	\Tester\Assert::equal(2, $countAfter);

	$this->repository->delete(2);
	$this->repository->delete(3);
    }

}

\id(new TheaterRepositoryTest($container))->run();

bootstrap.php (upravený app/bootstrap)

<?php

// Load Nette Framework or autoloader generated by Composer
require __DIR__ . '/../libs/autoload.php';
require __DIR__ . '/../tests/bootstrap.php';

$configurator = new Nette\Config\Configurator;

// Enable Nette Debugger for error visualisation & logging
//$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/../log');

// Specify folder for cache
$configurator->setTempDirectory(__DIR__ . '/../temp');

// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
	->addDirectory(__DIR__)
	->addDirectory(__DIR__ . '/../libs')
	->register();

// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon', $configurator::NONE); // none section
$container = $configurator->createContainer();

return $container;

při spuštění testu mi to hodí v příkazové řádce Server Error. Když zakomentuju všehny metody test, tak to žádný internal error nehodí. Fakt jsem nenašel, jak to tedy dělat. Budu rád, když mi někdo poradí, co dělám špatně. Děkuji