I have the following catalogs structure:
composer.json
behat.yml
src
|--AppBundle
|--Features
|--example.feature
|--Context
|--FeatureContext.php
And the following behat.yml
default:
autoload:
'': 'src/AppBundle/Features/Context'
suites:
default:
paths: ['src/AppBundle/Features']
contexts:
- FeatureContext:
session: '@session'
# and extensions standard for Symphony
And FeatureContext.php contains
<?php
//namespace AppBundle\Features\Context;
use Behat\Behat\Context\Context;
use Behat\MinkExtension\Context\MinkContext;
/**
* Defines application features from the specific context.
*/
class FeatureContext extends MinkContext implements Context
{ ... }
There is commented namespace. When I run behat, now context is found correctly. When I uncomment namespace there occurs error:
[Behat\Behat\Context\Exception\ContextNotFoundException]
FeatureContext
context class not found and can not be used.
How to make it working when namespace in FeatureContext.php is uncommented? I do not know much about PSR-0 and PSR-4, but if problem can be connected with this i append fragment of composer.json.
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
I looking for best practices of coding, so if I am doing something in bad way I vote up for appropriate suggestion.
- I seem I should have namespace in FeatureContext.php, shouldn't I?
- I seem I shouldn't use PSR-0 in composer.json, should I?