You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 line
2.4KB

  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. namespace yii\test;
  8. use yii\base\Component;
  9. /**
  10. * Fixture represents a fixed state of a test environment.
  11. *
  12. * Each fixture instance represents a particular aspect of a test environment. For example,
  13. * you may use `UserFixture` to initialize the user database table with a set of known data. You may
  14. * load the fixture when running every test method so that the user table always contains the fixed data
  15. * and thus allows your test predictable and repeatable.
  16. *
  17. * A fixture may depend on other fixtures, specified via the [[depends]] property. When a fixture is being loaded,
  18. * its dependent fixtures will be automatically loaded BEFORE the fixture; and when the fixture is being unloaded,
  19. * its dependent fixtures will be unloaded AFTER the fixture.
  20. *
  21. * You should normally override [[load()]] to specify how to set up a fixture; and override [[unload()]]
  22. * for clearing up a fixture.
  23. *
  24. * @author Qiang Xue <qiang.xue@gmail.com>
  25. * @since 2.0
  26. */
  27. class Fixture extends Component
  28. {
  29. /**
  30. * @var array the fixtures that this fixture depends on. This must be a list of the dependent
  31. * fixture class names.
  32. */
  33. public $depends = [];
  34. /**
  35. * Loads the fixture.
  36. * This method is called before performing every test method.
  37. * You should override this method with concrete implementation about how to set up the fixture.
  38. */
  39. public function load()
  40. {
  41. }
  42. /**
  43. * This method is called BEFORE any fixture data is loaded for the current test.
  44. */
  45. public function beforeLoad()
  46. {
  47. }
  48. /**
  49. * This method is called AFTER all fixture data have been loaded for the current test.
  50. */
  51. public function afterLoad()
  52. {
  53. }
  54. /**
  55. * Unloads the fixture.
  56. * This method is called after every test method finishes.
  57. * You may override this method to perform necessary cleanup work for the fixture.
  58. */
  59. public function unload()
  60. {
  61. }
  62. /**
  63. * This method is called BEFORE any fixture data is unloaded for the current test.
  64. */
  65. public function beforeUnload()
  66. {
  67. }
  68. /**
  69. * This method is called AFTER all fixture data have been unloaded for the current test.
  70. */
  71. public function afterUnload()
  72. {
  73. }
  74. }