Completed
Push — refactor-db-tests ( 8ba032...86f17c )
by Carsten
10:02
created

Fixture::unload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\test;
9
10
use yii\base\Component;
11
12
/**
13
 * Fixture represents a fixed state of a test environment.
14
 *
15
 * Each fixture instance represents a particular aspect of a test environment. For example,
16
 * you may use `UserFixture` to initialize the user database table with a set of known data. You may
17
 * load the fixture when running every test method so that the user table always contains the fixed data
18
 * and thus allows your test predictable and repeatable.
19
 *
20
 * A fixture may depend on other fixtures, specified via the [[depends]] property. When a fixture is being loaded,
21
 * its dependent fixtures will be automatically loaded BEFORE the fixture; and when the fixture is being unloaded,
22
 * its dependent fixtures will be unloaded AFTER the fixture.
23
 *
24
 * You should normally override [[load()]] to specify how to set up a fixture; and override [[unload()]]
25
 * for clearing up a fixture.
26
 *
27
 * @author Qiang Xue <[email protected]>
28
 * @since 2.0
29
 */
30
class Fixture extends Component
31
{
32
    /**
33
     * @var array the fixtures that this fixture depends on. This must be a list of the dependent
34
     * fixture class names.
35
     */
36
    public $depends = [];
37
38
39
    /**
40
     * Loads the fixture.
41
     * This method is called before performing every test method.
42
     * You should override this method with concrete implementation about how to set up the fixture.
43
     */
44
    public function load()
45
    {
46
    }
47
48
    /**
49
     * This method is called BEFORE any fixture data is loaded for the current test.
50
     */
51 12
    public function beforeLoad()
52
    {
53 12
    }
54
55
    /**
56
     * This method is called AFTER all fixture data have been loaded for the current test.
57
     */
58 12
    public function afterLoad()
59
    {
60 12
    }
61
62
    /**
63
     * Unloads the fixture.
64
     * This method is called after every test method finishes.
65
     * You may override this method to perform necessary cleanup work for the fixture.
66
     */
67 6
    public function unload()
68
    {
69 6
    }
70
71
    /**
72
     * This method is called BEFORE any fixture data is unloaded for the current test.
73
     */
74 15
    public function beforeUnload()
75
    {
76 15
    }
77
78
    /**
79
     * This method is called AFTER all fixture data have been unloaded for the current test.
80
     */
81 15
    public function afterUnload()
82
    {
83 15
    }
84
}
85