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
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
class GenerateStepObjectTest extends BaseCommandRunner
{
protected function setUp()
{
$this->makeCommand('\Codeception\Command\GenerateStepObject');
$this->config = array(
'actor' => 'HobbitGuy',
'path' => 'tests/shire',
);
}
public function testBasic()
{
$this->execute(array('suite' => 'shire', 'step' => 'Login', '--silent' => true));
$generated = $this->log[0];
$this->assertEquals(\Codeception\Configuration::supportDir().'Step/Shire/Login.php', $generated['filename']);
$this->assertContains('class Login extends \HobbitGuy', $generated['content']);
$this->assertContains('namespace Step\\Shire;', $generated['content']);
$this->assertIsValidPhp($generated['content']);
$this->assertIsValidPhp($this->content);
}
public function testNamespace()
{
$this->config['namespace'] = 'MiddleEarth';
$this->execute(array('suite' => 'shire', 'step' => 'Login', '--silent' => true));
$generated = $this->log[0];
$this->assertEquals(\Codeception\Configuration::supportDir().'Step/Shire/Login.php', $generated['filename']);
$this->assertContains('namespace MiddleEarth\Step\Shire;', $generated['content']);
$this->assertContains('class Login extends \MiddleEarth\HobbitGuy', $generated['content']);
$this->assertIsValidPhp($generated['content']);
$this->assertIsValidPhp($this->content);
}
public function testCreateInSubpath()
{
$this->execute(array('suite' => 'shire', 'step' => 'User/Login', '--silent' => true));
$generated = $this->log[0];
$this->assertEquals(
\Codeception\Configuration::supportDir().'Step/Shire/User/Login.php',
$generated['filename']
);
$this->assertIsValidPhp($this->content);
}
}