Repository navigation
Expand file tree
/
Copy pathParserTest.php
More file actions
81 lines (69 loc) · 2.77 KB
/
Copy pathParserTest.php
File metadata and controls
81 lines (69 loc) · 2.77 KB
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
71
72
73
74
75
76
77
78
79
80
81
<?php
use \Codeception\Util\Stub;
class ParserTest extends \Codeception\TestCase\Test
{
/**
* @var \Codeception\Parser
*/
private $parser;
/**
* @var \CodeGuy
*/
protected $codeGuy;
protected function _before()
{
$this->scenario = new \Codeception\Scenario(Stub::make('Codeception\TestCase\Cept'));
$this->parser = new \Codeception\Parser($this->scenario);
}
public function testParsingFeature()
{
$code = "<?php\n \\\$I->wantTo('run this test'); ";
$this->parser->parseFeature($code);
$this->assertEquals('run this test', $this->scenario->getFeature());
$code = "<?php\n \\\$I->wantToTest('this run'); ";
$this->parser->parseFeature($code);
$this->assertEquals('test this run', $this->scenario->getFeature());
}
public function testScenarioOptions()
{
$code = "<?php\n \$scenario->group('davert'); \$scenario->env('windows');";
$this->parser->parseScenarioOptions($code);
$this->assertContains('davert', $this->scenario->getGroups());
$this->assertContains('windows', $this->scenario->getEnv());
}
public function testScenarioSkipOptionsHandled()
{
$this->setExpectedException('PHPUnit_Framework_SkippedTestError', 'pass along');
$code = "<?php\n \$scenario->skip('pass along'); ";
$this->parser->parseScenarioOptions($code);
$this->assertTrue($this->scenario->isBlocked());
$this->scenario->run();
}
public function testScenarioIncompleteOptionHandled()
{
$this->setExpectedException('PHPUnit_Framework_IncompleteTestError', 'not ready yet');
$code = "<?php\n \$scenario->incomplete('not ready yet'); ";
$this->parser->parseScenarioOptions($code);
$this->assertTrue($this->scenario->isBlocked());
$this->scenario->run();
}
public function testSteps()
{
$code = file_get_contents(\Codeception\Configuration::projectDir().'tests/cli/UnitCept.php');
$this->assertContains('$I->seeInThisFile', $code);
$this->parser->parseSteps($code);
$text = $this->scenario->getText();
$this->assertContains("I see in this file", $text);
$this->assertContains('I see in this file \'<testsuite name="unit" tests="5" assertions="5"', $text);
}
public function testStepsWithFriends()
{
$code = file_get_contents(\Codeception\Configuration::projectDir().'tests/web/FriendsCept.php');
$this->assertContains('$I->haveFriend', $code);
$this->parser->parseSteps($code);
$text = $this->scenario->getText();
$this->assertContains("jon does", $text);
$this->assertContains("I have friend", $text);
$this->assertContains("back to me", $text);
}
}