diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f653150..6d6f5c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.4, 8.0, 8.1] steps: - name: Checkout code diff --git a/composer.json b/composer.json index 0b5911b..6dfb60a 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "minimum-stability": "RC", "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8.0", "codeception/codeception": "^4.0", "league/factory-muffin": "^3.0", "league/factory-muffin-faker": "^2.1" diff --git a/readme.md b/readme.md index dc77128..11ac0e5 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ A data factory module for Codeception. ## Requirements -* `PHP 7.1` or higher. +* `PHP 7.4` or higher. ## Installation diff --git a/src/Codeception/Module/DataFactory.php b/src/Codeception/Module/DataFactory.php index 7f0acdc..272400e 100644 --- a/src/Codeception/Module/DataFactory.php +++ b/src/Codeception/Module/DataFactory.php @@ -158,10 +158,7 @@ */ class DataFactory extends \Codeception\Module implements DependsOnModule, RequiresPackage { - /** - * @var string - */ - protected $dependencyMessage = << '"league/factory-muffin": "^3.0"', + FactoryMuffin::class => '"league/factory-muffin": "^3.0"', ]; } @@ -206,15 +198,13 @@ public function _beforeSuite($settings = []) if ($realpath === false) { throw new ModuleException($this, 'The path to one of your factories is not correct. Please specify the directory relative to the codeception.yml file (ie. _support/factories).'); } + $this->factoryMuffin->loadFactories($realpath); } } } - /** - * @return StoreInterface|null - */ - protected function getStore() + protected function getStore(): ?StoreInterface { if (!empty($this->config['customStore'])) { $store = new $this->config['customStore']; @@ -242,18 +232,19 @@ public function _after(TestInterface $test) if ($skipCleanup) { return; } + if ($cleanupOrmModule_Config) { return; } + $this->factoryMuffin->deleteSaved(); } public function _depends() { - return [\Codeception\Lib\Interfaces\ORM::class => $this->dependencyMessage]; + return [ORM::class => $this->dependencyMessage]; } - /** * @throws ModuleException */ @@ -263,6 +254,7 @@ public function onReconfigure($settings = []) if (!$skipCleanup && !$this->ormModule->_getConfig('cleanup')) { $this->factoryMuffin->deleteSaved(); } + $this->_beforeSuite($settings); } @@ -274,7 +266,6 @@ public function onReconfigure($settings = []) * 'name' => $faker->name, * 'email' => $faker->email * ]); - * * ``` * * @throws \League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException @@ -293,10 +284,8 @@ public function _define(string $model, array $fields): Definition * ``` * * Returns an instance of created user. - * - * @return object */ - public function have(string $name, array $extraAttrs = []) + public function have(string $name, array $extraAttrs = []): object { return $this->factoryMuffin->create($name, $extraAttrs); } @@ -312,10 +301,8 @@ public function have(string $name, array $extraAttrs = []) * ``` * * Returns an instance of created user without creating a record in database. - * - * @return object */ - public function make(string $name, array $extraAttrs = []) + public function make(string $name, array $extraAttrs = []): object { return $this->factoryMuffin->instance($name, $extraAttrs); }