Skip to content

Commit 7056352

Browse files
committed
Added package files
1 parent 8f6f317 commit 7056352

13 files changed

+249
-2
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Exclude files that don't need to be present in packages (so they're not downloaded by Composer)
2+
/tests export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/Robofile.php export-ignore
6+
/*.md export-ignore
7+
/*.yml export-ignore

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/vendor/
3+
/composer.lock

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
- 7.2
8+
- 7.3
9+
10+
# faster builds on new travis setup not using sudo
11+
sudo: false
12+
13+
install:
14+
- '[[ -z "$CI_USER_TOKEN" ]] || composer config github-oauth.github.com ${CI_USER_TOKEN};'
15+
- travis_retry composer self-update && composer --version
16+
- travis_retry composer update --prefer-dist --no-interaction
17+
18+
script:
19+
- php ./vendor/bin/codecept run

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2011 Michael Bodnarchuk and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Robofile.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require __DIR__ . '/vendor/autoload.php';
4+
5+
use Codeception\Module\Sequence;
6+
use Codeception\Util\DocumentationHelpers;
7+
8+
class RoboFile extends \Robo\Tasks
9+
{
10+
use DocumentationHelpers;
11+
12+
public function buildDocs()
13+
{
14+
$className = Sequence::class;
15+
$classPath = str_replace('\\', '/', $className);
16+
$source = "https://github.com/Codeception/module-sequence/tree/master/src/$classPath.php";
17+
$sourceMessage = '<p>&nbsp;</p><div class="alert alert-warning">Module reference is taken from the source code. <a href="' . $source . '">Help us to improve documentation. Edit module reference</a></div>';
18+
$documentationFile = 'documentation.md';
19+
$this->generateDocumentationForClass($className, $documentationFile, $sourceMessage);
20+
}
21+
}

codeception.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
paths:
2+
tests: tests
3+
output: tests/_output
4+
data: tests/_data
5+
support: tests/_support
6+
envs: tests/_envs
7+
actor_suffix: Tester

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name":"codeception/module-sequence",
3+
"description":"Sequence module for Codeception",
4+
"keywords":["codeception"],
5+
"homepage":"http://codeception.com/",
6+
"type":"library",
7+
"license":"MIT",
8+
"authors":[
9+
{
10+
"name":"Michael Bodnarchuk"
11+
}
12+
],
13+
"minimum-stability": "RC",
14+
15+
"require": {
16+
"php": ">=5.6.0 <8.0",
17+
"codeception/codeception": "4.0.x-dev | ^4.0"
18+
},
19+
"require-dev": {
20+
"codeception/util-robohelpers": "dev-master"
21+
},
22+
"autoload":{
23+
"classmap": ["src/"]
24+
},
25+
"config": {
26+
"classmap-authoritative": true
27+
}
28+
}

documentation.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Sequence
2+
3+
4+
Sequence solves data cleanup issue in alternative way.
5+
Instead cleaning up the database between tests,
6+
you can use generated unique names, that should not conflict.
7+
When you create article on a site, for instance, you can assign it a unique name and then check it.
8+
9+
This module has no actions, but introduces a function `sq` for generating unique sequences within test and
10+
`sqs` for generating unique sequences across suite.
11+
12+
### Usage
13+
14+
Function `sq` generates sequence, the only parameter it takes, is id.
15+
You can get back to previously generated sequence using that id:
16+
17+
``` php
18+
<?php
19+
sq('post1'); // post1_521fbc63021eb
20+
sq('post2'); // post2_521fbc6302266
21+
sq('post1'); // post1_521fbc63021eb
22+
```
23+
24+
Example:
25+
26+
``` php
27+
<?php
28+
$I->wantTo('create article');
29+
$I->click('New Article');
30+
$I->fillField('Title', sq('Article'));
31+
$I->fillField('Body', 'Demo article with Lorem Ipsum');
32+
$I->click('save');
33+
$I->see(sq('Article') ,'#articles')
34+
```
35+
36+
Populating Database:
37+
38+
``` php
39+
<?php
40+
41+
for ($i = 0; $i<10; $i++) {
42+
$I->haveInDatabase('users', array('login' => sq("user$i"), 'email' => sq("user$i").'@email.com');
43+
}
44+
?>
45+
```
46+
47+
Cest Suite tests:
48+
49+
``` php
50+
<?php
51+
class UserTest
52+
{
53+
public function createUser(AcceptanceTester $I)
54+
{
55+
$I->createUser(sqs('user') . '@mailserver.com', sqs('login'), sqs('pwd'));
56+
}
57+
58+
public function checkEmail(AcceptanceTester $I)
59+
{
60+
$I->seeInEmailTo(sqs('user') . '@mailserver.com', sqs('login'));
61+
}
62+
63+
public function removeUser(AcceptanceTester $I)
64+
{
65+
$I->removeUser(sqs('user') . '@mailserver.com');
66+
}
67+
}
68+
?>
69+
```
70+
71+
### Config
72+
73+
By default produces unique string with param as a prefix:
74+
75+
```
76+
sq('user') => 'user_876asd8as87a'
77+
```
78+
79+
This behavior can be configured using `prefix` config param.
80+
81+
Old style sequences:
82+
83+
```yaml
84+
Sequence:
85+
prefix: '_'
86+
```
87+
88+
Using id param inside prefix:
89+
90+
```yaml
91+
Sequence:
92+
prefix: '{id}.'
93+
```
94+
95+
## Actions
96+
97+
<p>&nbsp;</p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/module-sequence/tree/master/src/Codeception/Module/Sequence.php">Help us to improve documentation. Edit module reference</a></div>

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Sequence module for Codeception
2+
3+
[![Build Status](https://travis-ci.org/Codeception/module-sequence.svg?branch=master)](https://travis-ci.org/Codeception/module-sequence)
4+
5+
## Installation
6+
7+
```
8+
composer require --dev "codeception/module-sequence"
9+
```
10+
11+
## Documentation
12+
13+
<a href="documentation.md">Look at documentation.md file</a>

tests/_support/UnitTester.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
4+
/**
5+
* Inherited Methods
6+
* @method void wantToTest($text)
7+
* @method void wantTo($text)
8+
* @method void execute($callable)
9+
* @method void expectTo($prediction)
10+
* @method void expect($prediction)
11+
* @method void amGoingTo($argumentation)
12+
* @method void am($role)
13+
* @method void lookForwardTo($achieveValue)
14+
* @method void comment($description)
15+
* @method void pause()
16+
*
17+
* @SuppressWarnings(PHPMD)
18+
*/
19+
class UnitTester extends \Codeception\Actor
20+
{
21+
use _generated\UnitTesterActions;
22+
23+
/**
24+
* Define custom actions here
25+
*/
26+
}

tests/_support/_generated/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.php

tests/unit.suite.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error_level: "E_ALL | E_STRICT"
2+
class_name: UnitTester

tests/unit/Codeception/Module/SequenceTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class SequenceTest extends \Codeception\Test\Unit
55
// tests
66
public function testSequences()
77
{
8-
$module = new \Codeception\Module\Sequence(make_container());
8+
$container = \Codeception\Util\Stub::make('Codeception\Lib\ModuleContainer');
9+
$module = new \Codeception\Module\Sequence($container);
910
$this->assertNotEquals(sq(), sq());
1011
$this->assertNotEquals(sq(1), sq(2));
1112
$this->assertEquals(sq(1), sq(1));
@@ -16,7 +17,8 @@ public function testSequences()
1617

1718
public function testSuiteSequences()
1819
{
19-
$module = new \Codeception\Module\Sequence(make_container());
20+
$container = \Codeception\Util\Stub::make('Codeception\Lib\ModuleContainer');
21+
$module = new \Codeception\Module\Sequence($container);
2022
$this->assertNotEquals(sqs(), sqs());
2123
$this->assertNotEquals(sqs(1), sqs(2));
2224
$this->assertEquals(sqs(1), sqs(1));

0 commit comments

Comments
 (0)