yii2

Форк
1
/
Fixture.php 
86 строк · 2.5 Кб
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://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
 * For more details and usage information on Fixture, see the [guide article on fixtures](guide:test-fixtures).
28
 *
29
 * @author Qiang Xue <qiang.xue@gmail.com>
30
 * @since 2.0
31
 */
32
class Fixture extends Component
33
{
34
    /**
35
     * @var array the fixtures that this fixture depends on. This must be a list of the dependent
36
     * fixture class names.
37
     */
38
    public $depends = [];
39

40

41
    /**
42
     * Loads the fixture.
43
     * This method is called before performing every test method.
44
     * You should override this method with concrete implementation about how to set up the fixture.
45
     */
46
    public function load()
47
    {
48
    }
49

50
    /**
51
     * This method is called BEFORE any fixture data is loaded for the current test.
52
     */
53
    public function beforeLoad()
54
    {
55
    }
56

57
    /**
58
     * This method is called AFTER all fixture data have been loaded for the current test.
59
     */
60
    public function afterLoad()
61
    {
62
    }
63

64
    /**
65
     * Unloads the fixture.
66
     * This method is called after every test method finishes.
67
     * You may override this method to perform necessary cleanup work for the fixture.
68
     */
69
    public function unload()
70
    {
71
    }
72

73
    /**
74
     * This method is called BEFORE any fixture data is unloaded for the current test.
75
     */
76
    public function beforeUnload()
77
    {
78
    }
79

80
    /**
81
     * This method is called AFTER all fixture data have been unloaded for the current test.
82
     */
83
    public function afterUnload()
84
    {
85
    }
86
}
87

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.