/
FixturizedTestCase.php
83 lines (74 loc) · 1.87 KB
/
FixturizedTestCase.php
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
82
83
<?php
namespace Cake\Test\Fixture;
use Cake\TestSuite\TestCase;
use Exception;
/**
* This class helps in testing the life-cycle of fixtures inside a CakeTestCase
*/
class FixturizedTestCase extends TestCase
{
/**
* Fixtures to use in this test
* @var array
*/
public $fixtures = ['core.Categories', 'core.Articles'];
/**
* test that the shared fixture is correctly set
*
* @return void
*/
public function testFixturePresent()
{
$this->assertInstanceOf('Cake\TestSuite\Fixture\FixtureManager', $this->fixtureManager);
}
/**
* test that it is possible to load fixtures on demand
*
* @return void
*/
public function testFixtureLoadOnDemand()
{
$this->loadFixtures('Categories');
}
/**
* test that calling loadFixtures without args loads all fixtures
*
* @return void
*/
public function testLoadAllFixtures()
{
$this->loadFixtures();
$article = $this->getTableLocator()->get('Articles')->get(1);
$this->assertSame(1, $article->id);
$category = $this->getTableLocator()->get('Categories')->get(1);
$this->assertSame(1, $category->id);
}
/**
* test that a test is marked as skipped using skipIf and its first parameter evaluates to true
*
* @return void
*/
public function testSkipIfTrue()
{
$this->skipIf(true);
}
/**
* test that a test is not marked as skipped using skipIf and its first parameter evaluates to false
*
* @return void
*/
public function testSkipIfFalse()
{
$this->skipIf(false);
}
/**
* test that a fixtures are unloaded even if the test throws exceptions
*
* @return void
* @throws \Exception
*/
public function testThrowException()
{
throw new Exception();
}
}