Testování komponent – připojení presenteru
- tttpapi
- Člen | 100
Ahoj,
našel jsem tu na fóru otázku (https://forum.nette.org/…a-presenteru),
ze které jsem se ale nedozvěděl, jak tuto komponentu k presenteru
přiřadím.
Pokud test spustím bez presenteru, tak dostanu chybu:
Nette\InvalidStateException: Component '' is not attached to
‚Nette\Application\UI\Presenter‘.
Pokud zkusím přidat presenter, ať už přes
createPresenter() nebo pomocí new, tak mi
vyskočí chyba:
Nette\Database\ConnectionException: could not find driver
Jak si zajistím, že je presenter svázán s komponentou a já můžu testovat handle metody, které upraví $this->template->…?
Celá chybová hláška:
-- FAILED: nette\tests\ShoppingCartListTest.phpt
Nette\Database\ConnectionException: could not find driver
in src\Database\DriverException.php(25)
in src\Database\Connection.php(73) Nette\Database\DriverException::from()
in src\Database\Connection.php(57) Nette\Database\Connection->connect()
in cache\Nette.Configurator\Container_f057f3e71b.php(1245) Nette\Database\Con
nection->__construct()
in [internal function]Container_f057f3e71b->createServiceDatabase__default__c
onnection()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(1256) Nette\DI\Container
->getService()
in [internal function]Container_f057f3e71b->createServiceDatabase__default__c
ontext()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(811) Nette\DI\Container-
>getService()
in [internal function]Container_f057f3e71b->createService__34_App_Model_UserR
epository()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(740) Nette\DI\Container-
>getService()
in [internal function]Container_f057f3e71b->createService__27_App_Model_Authe
nticator()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(1404) Nette\DI\Container
->getService()
in [internal function]Container_f057f3e71b->createServiceSecurity__user()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in src\DI\Container.php(186) Nette\DI\Container->getService()
in src\DI\Helpers.php(104) Nette\DI\Container->getByType()
in src\DI\Container.php(269) Nette\DI\Helpers::autowireArguments()
in DI\Extensions\InjectExtension.php(108) Nette\DI\Container->callMethod()
in src\DI\Container.php(255) Nette\DI\Extensions\InjectExtension::callInjects
()
in Bridges\ApplicationDI\PresenterFactoryCallback.php(52) Nette\DI\Container-
>callInjects()
in [internal function]Nette\Bridges\ApplicationDI\PresenterFactoryCallback->_
_invoke()
in src\Application\PresenterFactory.php(52) call_user_func()
in nette\tests\ShoppingCartListTest.phpt(24) Nette\Application\PresenterFacto
ry->createPresenter()
in nette\tests\ShoppingCartListTest.phpt(256) ShoppingCartListTest->__constru
ct()
(previous) PDOException: could not find driver
in src\Database\Connection.php(70)
in src\Database\Connection.php(70) PDO->__construct()
in src\Database\Connection.php(57) Nette\Database\Connection->connect()
in cache\Nette.Configurator\Container_f057f3e71b.php(1245) Nette\Database\Con
nection->__construct()
in [internal function]Container_f057f3e71b->createServiceDatabase__default__c
onnection()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(1256) Nette\DI\Container
->getService()
in [internal function]Container_f057f3e71b->createServiceDatabase__default__c
ontext()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(811) Nette\DI\Container-
>getService()
in [internal function]Container_f057f3e71b->createService__34_App_Model_UserR
epository()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(740) Nette\DI\Container-
>getService()
in [internal function]Container_f057f3e71b->createService__27_App_Model_Authe
nticator()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in cache\Nette.Configurator\Container_f057f3e71b.php(1404) Nette\DI\Container
->getService()
in [internal function]Container_f057f3e71b->createServiceSecurity__user()
in src\DI\Container.php(159) call_user_func_array()
in src\DI\Container.php(105) Nette\DI\Container->createService()
in src\DI\Container.php(186) Nette\DI\Container->getService()
in src\DI\Helpers.php(104) Nette\DI\Container->getByType()
in src\DI\Container.php(269) Nette\DI\Helpers::autowireArguments()
in DI\Extensions\InjectExtension.php(108) Nette\DI\Container->callMethod()
in src\DI\Container.php(255) Nette\DI\Extensions\InjectExtension::callInjects
()
in Bridges\ApplicationDI\PresenterFactoryCallback.php(52) Nette\DI\Container-
>callInjects()
in [internal function]Nette\Bridges\ApplicationDI\PresenterFactoryCallback->_
_invoke()
in src\Application\PresenterFactory.php(52) call_user_func()
in nette\tests\ShoppingCartListTest.phpt(24) Nette\Application\PresenterFacto
ry->createPresenter()
in nette\tests\ShoppingCartListTest.phpt(256) ShoppingCartListTest->__constru
ct()
- Blujacker
- Člen | 89
Tester pousti testy bez defaultniho php.ini souboru, kde se dost casto inkluduji ruzne rozsireni (PDO, …). Takze aby se testy pustili s temito rozsirenimi, musi se udelat vlastni php.ini, treba
[PHP]
extension=json.so
extension=pdo.so
extension=mysql.so
extension=pdo_mysql.so
extension=gettext.so
extension=/usr/local/xdebug/xdebug.so
a pak testy poustet treba takto
php -c tests/php.ini vendor/nette/tester/src/tester.php -p php -c tests/php.ini tests
- tttpapi
- Člen | 100
Zkusil jsem přidat php.ini s nastavením z dokumentace:
[PHP]
extension=php_pdo_mysql.dll
memory_limit=512M
Spouštím to příkazem: vendor\bin\tester.bat -c tests\php.ini tests\ShoppingCartListTest.phpt
Hlasí mi to ale pořád tu samou chybu.
Nette\Database\ConnectionException: could not find driver
(previous) PDOException: could not find driver
- David Matějka
- Moderator | 6445
a pouzivas mysql? zkus pustit tester s -i prepinacem, jestli je pdo a pdo_mysql nacteno
- tttpapi
- Člen | 100
Ano, používám mysql.
Tohle je výpis z -i:
PHP binary:
C:\UwAmp\bin\php\default php-5.5.15\php-cgi.exe
PHP version:
5.5.15 (cgi-fcgi)
Loaded php.ini files:
C:\localhost\knihy\nette\tests\php.ini
Loaded extensions:
bcmath, calendar, cgi-fcgi, Core, ctype, date, dom, ereg, filter, ftp, hash, ico
nv, json, libxml, mcrypt, mhash, mysqlnd, odbc, pcre, PDO, Phar, Reflection, ses
sion, SimpleXML, SPL, standard, tokenizer, wddx, xml, xmlreader, xmlwriter, zip,
zlib