Repository navigation
Expand file tree
/
Copy pathTestCaseTest.php
More file actions
65 lines (57 loc) · 2.11 KB
/
Copy pathTestCaseTest.php
File metadata and controls
65 lines (57 loc) · 2.11 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
<?php
class TestCaseTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Codeception\TestCase
*/
protected $testcase;
/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
protected $dispatcher;
public function setUp() {
$this->dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher;
$this->testcase = $this->getMockForAbstractClass('\Codeception\TestCase\Cept', array(
$this->dispatcher, array(
'name' => 'mocked test',
'file' => \Codeception\Configuration::dataDir().'SimpleCept.php'
)
));
\Codeception\SuiteManager::$modules['EmulateModuleHelper']->assertions = 0;
}
/**
* @group core
*/
public function testRunStepEvents() {
$events = array();
$this->dispatcher->addListener('step.before', function () use (&$events) { $events[] = 'step.before'; });
$this->dispatcher->addListener('step.after', function () use (&$events) { $events[] = 'step.after'; });
$step = new \Codeception\Step\Action('seeEquals', array(5,5));
$this->testcase->runStep($step);
$this->assertEquals($events, array('step.before', 'step.after'));
}
/**
* @group core
*/
public function testRunStep() {
$assertions = &\Codeception\SuiteManager::$modules['EmulateModuleHelper']->assertions;
$step = new \Codeception\Step\Action('seeEquals', array(5,5));
$this->testcase->runStep($step);
$this->assertEquals(1, $assertions);
$step = new \Codeception\Step\Action('seeEquals', array(5,6));
try {
$this->testcase->runStep($step);
} catch (Exception $e) {
$this->assertInstanceOf('PHPUnit_Framework_ExpectationFailedException', $e);
}
$this->assertEquals(1, $assertions);
}
/**
* @group core
*/
public function testRunStepAddsTrace() {
$step = new \Codeception\Step\Action('seeEquals', array(5,5));
$this->testcase->runStep($step);
$this->assertContains($step, $this->testcase->getTrace());
}
}