Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
Change class alias prefix to behatch:context
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Nov 23, 2017
1 parent 700869a commit 83b6d37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
14 changes: 7 additions & 7 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ default:
paths: [ '%paths.base%/tests/features' ]
contexts:
- Behat\MinkExtension\Context\MinkContext
- behatch:browser:
- behatch:context:browser:
timeout: 1
- behatch:debug:
- behatch:context:debug:
screenshotDir: "."
- behatch:json:
- behatch:context:json:
evaluationMode: javascript
- behatch:rest
- behatch:system:
- behatch:context:rest
- behatch:context:system:
root: "."
- behatch:table
- behatch:xml
- behatch:context:table
- behatch:context:xml
extensions:
Behat\MinkExtension\ServiceContainer\MinkExtension:
base_url: 'http://localhost:8080'
Expand Down
26 changes: 5 additions & 21 deletions src/Context/ContextClass/ClassResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,15 @@ class ClassResolver implements BaseClassResolver
{
public function supportsClass($contextClass)
{
return (strpos($contextClass, 'behatch:') === 0);
return (strpos($contextClass, 'behatch:context:') === 0);
}

public function resolveClass($contextClass)
{
if (strpos($contextClass, 'behatch:context:') === false) {
list(, $className) = explode(':', $contextClass);
$className = preg_replace_callback('/(^\w|:\w)/', function ($matches) {
return str_replace(':', '\\', strtoupper($matches[0]));
}, $contextClass);

$className = ucfirst($className);

@trigger_error(
sprintf(
'Deprecated context alias use behatch:context:%s instead',
strtolower($className)
),
E_USER_DEPRECATED
);

return "\\Behatch\\Context\\{$className}Context";
} else {
$className = preg_replace_callback('/(^\w|:\w)/', function ($matches) {
return str_replace(':', '\\', strtoupper($matches[0]));
}, $contextClass);

return $className . 'Context';
}
return $className . 'Context';
}
}

0 comments on commit 83b6d37

Please sign in to comment.