Repository navigation
Expand file tree
/
Copy pathSuiteManagerTest.php
More file actions
60 lines (54 loc) · 2.44 KB
/
Copy pathSuiteManagerTest.php
File metadata and controls
60 lines (54 loc) · 2.44 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
<?php
class SuiteManagerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Codeception\SuiteManager
*/
protected $suiteman;
/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
protected $dispatcher;
public function setUp() {
$this->dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher;
$this->suiteman = new \Codeception\SuiteManager($this->dispatcher, 'suite', \Codeception\Configuration::$defaultSuiteSettings);
}
/**
* @group core
*/
public function testRun() {
$events = array();
$this->dispatcher->addListener('suite.before', function ($e) use (&$events) { $events[] = $e->getName(); });
$this->dispatcher->addListener('suite.after', function ($e) use (&$events) { $events[] = $e->getName(); });
$runner = new \Codeception\PHPUnit\Runner;
$runner->setPrinter(new PHPUnit_TextUI_ResultPrinter($this->dispatcher));
$this->suiteman->run($runner, new \PHPUnit_Framework_TestResult, array('colors' => false, 'steps' => true, 'debug' => false));
$this->assertEquals($events, array('suite.before', 'suite.after'));
}
/**
* @group core
*/
public function testFewTests() {
$file = \Codeception\Configuration::dataDir().'SimpleCest.php';
$this->suiteman->loadTests($file);
$this->assertEquals(2, $this->suiteman->getSuite()->count());
$file = \Codeception\Configuration::dataDir().'SimpleWithNoClassCest.php';
$this->suiteman->loadTests($file);
$this->assertEquals(3, $this->suiteman->getSuite()->count());
}
/**
* When running multiple environments, getClassesFromFile() method in SuiteManager is called once for each env.
* See \Codeception\Codecept::runSuite() - for each env new SuiteManager is created and tests loaded.
* Make sure that calling getClassesFromFile() multiple times will always return the same classes.
*
* @group core
*/
public function testAddCestWithEnv() {
$file = \Codeception\Configuration::dataDir().'SimpleNamespacedTest.php';
$this->suiteman->loadTests($file);
$this->assertEquals(3, $this->suiteman->getSuite()->count());
$newSuiteMan = new \Codeception\SuiteManager($this->dispatcher, 'suite', \Codeception\Configuration::$defaultSuiteSettings);
$newSuiteMan->loadTests($file);
$this->assertEquals(3, $newSuiteMan->getSuite()->count());
}
}