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
64
65
66
67
68
69
70
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'BaseCommandRunner.php';
class GeneratePageObjectTest extends BaseCommandRunner
{
protected function setUp()
{
$this->makeCommand('\Codeception\Command\GeneratePageObject');
$this->config = array(
'actor' => 'HobbitGuy',
'path' => 'tests/shire',
'paths' => array('tests' => 'tests'),
'settings' => array('bootstrap' => '_bootstrap.php')
);
}
public function testBasic()
{
unset($this->config['actor']);
$this->execute(array('suite' => 'Login'), false);
$this->assertEquals(\Codeception\Configuration::supportDir().'Page/Login.php', $this->filename);
$this->assertContains('class Login', $this->content);
$this->assertContains('public static', $this->content);
$this->assertNotContains('public function __construct', $this->content);
$this->assertIsValidPhp($this->content);
}
public function testNamespace()
{
unset($this->config['actor']);
$this->config['namespace'] = 'MiddleEarth';
$this->execute(array('suite' => 'Login'), false);
$this->assertEquals(\Codeception\Configuration::supportDir().'Page/Login.php', $this->filename);
$this->assertContains('namespace MiddleEarth\Page;', $this->content);
$this->assertContains('class Login', $this->content);
$this->assertContains('public static', $this->content);
$this->assertIsValidPhp($this->content);
}
public function testCreateForSuite()
{
$this->execute(array('suite' => 'shire', 'page' => 'Login'));
$this->assertEquals(\Codeception\Configuration::supportDir().'Page/Shire/Login.php', $this->filename);
$this->assertContains('namespace Page\Shire;', $this->content);
$this->assertContains('class Login', $this->content);
$this->assertContains('protected $hobbitGuy;', $this->content);
$this->assertContains('public function __construct(\HobbitGuy $I)', $this->content);
$this->assertIsValidPhp($this->content);
}
public function testCreateForSuiteWithNamespace()
{
$this->config['namespace'] = 'MiddleEarth';
$this->execute(array('suite' => 'shire', 'page' => 'Login'));
$this->assertEquals(\Codeception\Configuration::supportDir().'Page/Shire/Login.php', $this->filename);
$this->assertContains('namespace MiddleEarth\Page\Shire;', $this->content);
$this->assertContains('class Login', $this->content);
$this->assertContains('protected $hobbitGuy;', $this->content);
$this->assertContains('public function __construct(\MiddleEarth\HobbitGuy $I)', $this->content);
$this->assertIsValidPhp($this->content);
}
public function testCreateInSubpath()
{
$this->execute(array('suite' => 'User/View'));
$this->assertEquals(\Codeception\Configuration::supportDir().'Page/User/View.php', $this->filename);
$this->assertIsValidPhp($this->content);
}
}