Ambiguous class, stejna cesta, obracene lomitko
- libik
- Člen | 96
Ahoj,
zacinam si hrat s Nette testerem, ale pomerne brzy jsem se zasekl.
Mam strukturu
app
-IntraModule
- forms
- presenters
- ...
- presenters
- config
- ...
Testovaci Bootstrap takto:
require __DIR__ . '/../vendor/autoload.php';
Tester\Environment::setup();
$configurator = new Nette\Configurator;
$configurator->setDebugMode(FALSE);
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
->addDirectory(__DIR__ . '/../app')
->addDirectory(__DIR__ . '/../app/IntraModule')
->register();
$configurator->addConfig(__DIR__ . '/../app/config/config.neon');
$configurator->addConfig(__DIR__ . '/../app/config/config.local.neon');
return $configurator->createContainer();
Bez pridani /../app/IntraModule mi tester nenajde SignPresenter.
V ExampleTest:
function testSignIn()
{
$presenterFactory = $this->container->getByType('Nette\Application\IPresenterFactory');
$presenter = $presenterFactory->createPresenter('Sign');
$presenter->autoCanonicalize = FALSE;
$request = new Nette\Application\Request('Sign', 'GET', array('action' => 'in'));
$response = $presener->run($request);
Assert::type('Nette\Application\Responses\TextResponse', $response);
}
A test mi vraci:
`Exited with error code 255 (expected 0) Nette\InvalidStateException: Ambiguous
class App\IntraModule\Forms\CustomerFormFactory resolution; defined in
D:\www\projekt\intra.dtest.cz\tests/../app\IntraModule\forms\CustomerFormFactory.php
and in
D:\www\projekt\intra.dtest.cz\tests/../app/IntraModule\forms\CustomerFormFactory.php.
`
Nechapu kde se bere /app\IntraModule a \app\IntraModule, tedy odkaz na stejny skript, ale s obracenym lomitkem. Neni to nejaka Windows feature? Vyvijim na WampServeru.
- hitzoR
- Člen | 51
Předpokládám, že problém bude v tomhle:
$configurator->createRobotLoader()
->addDirectory(__DIR__ . '/../app')
->addDirectory(__DIR__ . '/../app/IntraModule')
->register();
Smaž ten řádek s /app/IntraModule, je tam zbytečně, protože RobotLoader prochází i podsložky, tzn. tuhle složku už si načte z definice /app.
Editoval hitzoR (5. 11. 2016 23:54)