Replies: 15 comments
|
Do you have any other suites? |
|
Just what's generated from the install/setup: cat tests/*.suite.yml
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
# acceptene.suite.yml
actor: AcceptanceTester
modules:
enabled:
- Symfony:
part: services
app_path: 'src'
environment: 'dev'
- PhpBrowser:
url: https://127.0.0.1:8000/ # http://mysite.wip
http_proxy: 127.0.0.1
http_proxy_port: 7080
- \App\Tests\Helper\Acceptance
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
# Remove this suite if you don't use frameworks
actor: FunctionalTester
modules:
enabled:
- Symfony:
app_path: 'src'
environment: 'test'
# - Doctrine2:
# depends: Symfony
# cleanup: true
- \App\Tests\Helper\Functional
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.
actor: UnitTester
modules:
enabled:
- Asserts
- \App\Tests\Helper\Unit
|
|
Is there a demo project I can add this to to show my issue? The Symfony demo + Codeception repo is pretty far out of date. I'll post a 6.1 version shortly. |
|
I've created a repo of the Symfony demo that shows the problem: https://github.com/tacman/codeception-symfony-demo It's the Symfony demo, with codeception installed (and some modules). The yaml files have changed, as above, and there's a trivial Listener that tries to get the module. But something's not right. PHPStorm hightlights the Symfony module as missing. Also, the constructor fails unless I explicitly create a contributor in my class, because $options isn't set. I think the parent class can safely make those an empty array. |
|
FWIW, the code I'm using used to access the Symfony module worked in an older version of Codeception. So I'm pretty sure I'm just configuring something incorrectly. I'm playing with a project that creates a detailed tutorial from a cest, but am stuck on the setup. Any help would be appreciated. Thanks. |
|
Any chance someone could take a look at what's wrong with my setup? It's just the symfony demo with codeception and an extension that tries to get a Symfony module. git clone https://github.com/tacman/codeception-symfony-demo && cd codeception-symfony-demo
composer install
symfony server:start -d
vendor/bin/codecept run -vI imagine it's a simple fix, some configuration issue, but I can't figure it out. Thanks. |
|
I continue to hack, unsuccessfully: public function afterSuite(SuiteEvent $e)
{
$suite = $e->getSuite();
$modules = $suite->getModules();
foreach ($modules as $module) {
if ($module->_getName() === 'Symfony') {
// throws Service `twig` is required by Codeception, but not loaded by Symfony since you're not using it anywhere in your app.
$twig = $module->grabService('twig');
//
}
}
assert($twig, "Twig is not loaded");
// this way throws an errror In Extension.php line 123:
// [Symfony] module requirements not met --
// module is not enabled
/** @var Symfony $symfony */
$symfony = $this->getModule('Symfony');
$twig = $symfony->grabService('twig');
}Can anyone point me to working example code that grabs a Symfony service in a Module Extension? @Naktibalda ? |
|
Sorry for late response. You enabled extension codeception.yml so it |
|
I don't understand. I've enabled it everywhere that I can think of (https://github.com/tacman/codeception-symfony-demo/blob/main/tests/unit.suite.yml). Can you give me an example of a configure that does work? |
|
The problem is that your extension overrides Either change public static function getSubscribedEvents(): array
{
return [
Events::SUITE_INIT => 'receiveModuleContainer',
Events::SUITE_AFTER => 'afterSuite',
];
}or delete public static array $events = [
Events::SUITE_AFTER => 'afterSuite',
]; |
|
Thanks! I'm making a bit of progress. Now it's got a strange error message: Of course, I tried making twig public in services.yaml, as suggested: Twig\Environment:
public: truebut it won't load correctly because it needs the file loader. And I can't simply inject twig in LoggerSubscriber. |
|
You services:
twig:
public: true
alias: Twig\EnvironmentBased on https://symfony.com/doc/current/service_container/alias_private.html#aliasing |
|
no, now the cache won't even clear. git clone https://github.com/tacman/codeception-symfony-demo twig-error && cd twig-error && composer install && vendor/bin/codecept run -v |
|
it is a Symfony configuration issue, I can't help with it. |
|
But this is the module-symfony library. Are there are projects that use it? Indeed, I haven't touched the symfony configuration, I've only configured this codeception yaml files. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm not configuring something correctly, but not sure what. It fails on getModule, so I'm probably not enabling the module correctly.
The error log
All reactions