diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d4e738..8ab4cff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [5.6, 7.0, 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 7291060..65f715f 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "minimum-stability": "RC", "require": { - "php": ">=5.6.0 <9.0", + "php": "^7.4 | ^8.0", "codeception/codeception": "^4.0" }, "autoload":{ diff --git a/readme.md b/readme.md index 0b9edbc..7bdcb58 100644 --- a/readme.md +++ b/readme.md @@ -1,11 +1,16 @@ -# Sequence module for Codeception +# Codeception Module Sequence + +Sequence module for Codeception. ![Build Status](https://github.com/Codeception/module-sequence/workflows/CI/badge.svg) +[![Latest Stable Version](https://poser.pugx.org/codeception/module-sequence/v/stable)](https://github.com/Codeception/module-sequence/releases) +[![Total Downloads](https://poser.pugx.org/codeception/module-sequence/downloads)](https://packagist.org/packages/codeception/module-sequence) +[![License](https://poser.pugx.org/codeception/module-sequence/license)](/LICENSE) ## Installation ``` -composer require --dev "codeception/module-sequence" +composer require "codeception/module-sequence" --dev ``` ## Documentation diff --git a/src/Codeception/Module/Sequence.php b/src/Codeception/Module/Sequence.php index 575010e..0678534 100644 --- a/src/Codeception/Module/Sequence.php +++ b/src/Codeception/Module/Sequence.php @@ -1,7 +1,10 @@ haveInDatabase('users', array('login' => sq("user$i"), 'email' => sq("user$i").'@email.com'); * } - * ?> * ``` * * Cest Suite tests: @@ -70,7 +72,6 @@ * $I->removeUser(sqs('user') . '@mailserver.com'); * } * } - * ?> * ``` * * ### Config @@ -97,12 +98,17 @@ * prefix: '{id}.' * ``` */ -class Sequence extends CodeceptionModule +class Sequence extends Module { - public static $hash = []; - public static $suiteHash = []; - public static $prefix = ''; + public static array $hash = []; + + public static array $suiteHash = []; + + public static string $prefix = ''; + /** + * @var array + */ protected $config = ['prefix' => '{id}_']; public function _initialize() @@ -124,5 +130,5 @@ public function _afterSuite() if (!function_exists('sq') && !function_exists('sqs')) { require_once __DIR__ . '/../Util/sq.php'; } else { - throw new ModuleException('Codeception\Module\Sequence', "function 'sq' and 'sqs' already defined"); + throw new ModuleException(Sequence::class, "function 'sq' and 'sqs' already defined"); } diff --git a/src/Codeception/Util/sq.php b/src/Codeception/Util/sq.php index f64e32f..49e04b9 100644 --- a/src/Codeception/Util/sq.php +++ b/src/Codeception/Util/sq.php @@ -1,17 +1,22 @@ assertNotEquals(sq(), sq()); - $this->assertNotEquals(sq(1), sq(2)); - $this->assertEquals(sq(1), sq(1)); - $old = sq(1); + $container = Stub::make(ModuleContainer::class); + $module = new Sequence($container); + $this->assertNotEquals(sq(''), sq('')); + $this->assertNotEquals(sq('1'), sq('2')); + $this->assertEquals(sq('1'), sq('1')); + $old = sq('1'); $module->_after($this); - $this->assertNotEquals($old, sq(1)); + $this->assertNotEquals($old, sq('1')); } - public function testSuiteSequences() + public function testSuiteSequences(): void { - $container = \Codeception\Util\Stub::make('Codeception\Lib\ModuleContainer'); - $module = new \Codeception\Module\Sequence($container); - $this->assertNotEquals(sqs(), sqs()); - $this->assertNotEquals(sqs(1), sqs(2)); - $this->assertEquals(sqs(1), sqs(1)); - $old = sqs(1); + $container = Stub::make(ModuleContainer::class); + $module = new Sequence($container); + $this->assertNotEquals(sqs('1'), sqs('2')); + $this->assertEquals(sqs('1'), sqs('1')); + $old = sqs('1'); $module->_after($this); - $this->assertEquals($old, sqs(1)); + $this->assertEquals($old, sqs('1')); $module->_afterSuite(); - $this->assertNotEquals($old, sqs(1)); + $this->assertNotEquals($old, sqs('1')); } }