1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Codeception\Lib\Generator;
use Codeception\Util\Shared\Namespaces;
use Codeception\Util\Template;
class Group
{
use Namespaces;
use Shared\Classname;
protected $template = <<<EOF
<?php
namespace {{namespace}};
use \Codeception\Event\TestEvent;
/**
* Group class is Codeception Extension which is allowed to handle to all internal events.
* This class itself can be used to listen events for test execution of one particular group.
* It may be especially useful to create fixtures data, prepare server, etc.
*
* INSTALLATION:
*
* To use this group extension, include it to "extensions" option of global Codeception config.
*/
class {{class}} extends \Codeception\Platform\Group
{
public static \$group = '{{groupName}}';
public function _before(TestEvent \$e)
{
}
public function _after(TestEvent \$e)
{
}
}
EOF;
protected $name;
protected $namespace;
protected $settings;
public function __construct($settings, $name)
{
$this->settings = $settings;
$this->name = $name;
$this->namespace = $this->getNamespaceString($this->settings['namespace'] . '\\Group\\' . $name);
}
public function produce()
{
$ns = $this->getNamespaceString($this->settings['namespace'] . '\\' . $this->name);
return (new Template($this->template))
->place('class', ucfirst($this->name))
->place('name', $this->name)
->place('namespace', $this->namespace)
->place('groupName', strtolower($this->name))
->produce();
}
}