Skip to content

Commit afc84ca

Browse files
authored
Merge pull request #2 from Arachne/refactoring
Refactoring
2 parents 40221c9 + 96d36ce commit afc84ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1094
-887
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
coverage_clover: tests/_log/coverage.xml
3+
json_path: tests/_log/coveralls.json

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
.coveralls.yml export-ignore
12
.gitattributes export-ignore
23
.gitignore export-ignore
3-
.gitlab-ci.yml export-ignore
4+
.php_cs export-ignore
45
.travis.yml export-ignore
56
codeception.yml export-ignore
6-
composer-*.json export-ignore
77
docs export-ignore
88
tests export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/tests/_temp/*
44
/composer*.lock
55

6+
.php_cs.cache
7+
68
!.gitkeep

.gitlab-ci.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.php_cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('_helpers')
5+
->exclude('_temp')
6+
->in(__DIR__)
7+
;
8+
9+
return PhpCsFixer\Config::create()
10+
->setRules(array(
11+
'@Symfony' => true,
12+
'combine_consecutive_unsets' => true,
13+
'linebreak_after_opening_tag' => true,
14+
'no_multiline_whitespace_before_semicolons' => true,
15+
'no_useless_else' => true,
16+
'no_useless_return' => true,
17+
'ordered_imports' => true,
18+
'phpdoc_order' => true,
19+
'short_array_syntax' => true,
20+
))
21+
->finder($finder)
22+
;

.travis.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
language: php
22

3-
env:
4-
matrix:
5-
- NETTE=nette-2.3
6-
- NETTE=nette-2.2 COMPOSER=composer-nette_2.2.json
7-
83
php:
9-
- 5.5
10-
- 5.6
11-
- 7.0
12-
- hhvm
4+
- 5.5
5+
- 5.6
6+
- 7.0
7+
- hhvm
8+
9+
matrix:
10+
allow_failures:
11+
- php: hhvm
1312

1413
before_install:
15-
- composer self-update
14+
- travis_retry composer self-update
1615

1716
install:
18-
- composer update --no-interaction --prefer-source
17+
- export PATH="$PATH:$HOME/.composer/vendor/bin"
18+
- travis_retry composer global require fabpot/php-cs-fixer "^2.0.0@dev"
19+
- travis_retry composer global require satooshi/php-coveralls "^1.0.0"
20+
- travis_retry composer update --no-interaction --prefer-source
1921

2022
before_script:
21-
- vendor/bin/phpcs -p --standard=vendor/arachne/coding-style/ruleset.xml --ignore=_* src tests
22-
- vendor/bin/codecept build
23+
- if [ $TRAVIS_PHP_VERSION != "hhvm" ]; then coverage="--coverage-xml"; fi
24+
- vendor/bin/codecept build
25+
26+
script:
27+
- php-cs-fixer fix --dry-run
28+
- vendor/bin/codecept run $coverage
2329

24-
script: vendor/bin/codecept run
30+
after_script:
31+
- if [ $coverage != "" ]; then coveralls --verbose; fi

codeception.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
actor: Tester
2+
13
paths:
24
tests: tests
35
log: tests/_log
46
data: tests/_data
5-
helpers: tests/_helpers
7+
support: tests/_helpers
68

79
settings:
810
bootstrap: _bootstrap.php
9-
suite_class: \PHPUnit_Framework_TestSuite
10-
colors: false
11-
memory_limit: 1024M
1211
log: true
1312

1413
extensions:

composer-nette_2.2.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

composer.json

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
{
2-
"name": "arachne/codeception",
3-
"type": "library",
4-
"keywords": [ "arachne", "codeception", "nette" ],
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "Jáchym Toušek",
9-
"homepage": "http://enumag.cz",
10-
"email": "enumag@gmail.com"
11-
}
12-
],
13-
"require": {
14-
"php": ">=5.5.0",
15-
"codeception/codeception": "~2.1",
16-
"nette/bootstrap": "~2.2",
17-
"nette/di": "~2.2",
18-
"nette/http": "~2.2"
19-
},
20-
"require-dev": {
21-
"arachne/bootstrap": "~0.2.1",
22-
"arachne/coding-style": "~0.3",
23-
"enumag/application": "~0.2",
24-
"latte/latte": "~2.2",
25-
"squizlabs/php_codesniffer": "~2.0",
26-
"tracy/tracy": "~2.2"
27-
},
28-
"autoload": {
29-
"psr-4": {
30-
"Arachne\\Codeception\\": "src"
31-
}
32-
},
33-
"autoload-dev": {
34-
"psr-4": {
35-
"Tests\\Unit\\": "tests/unit/src",
36-
"Tests\\Integration\\": "tests/integration/src"
37-
}
38-
}
2+
"name": "arachne/codeception",
3+
"description": "Integration of Nette framework to Codeception.",
4+
"type": "library",
5+
"keywords": [ "arachne", "codeception", "nette" ],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Jáchym Toušek",
10+
"homepage": "http://enumag.cz",
11+
"email": "enumag@gmail.com"
12+
}
13+
],
14+
"require": {
15+
"php": "^5.5.0|^7.0.0",
16+
"codeception/codeception": "^2.2.0",
17+
"nette/bootstrap": "^2.3.0",
18+
"nette/di": "^2.3.0",
19+
"nette/http": "^2.3.0"
20+
},
21+
"require-dev": {
22+
"arachne/bootstrap": "^0.2.1",
23+
"enumag/application": "^0.3.0",
24+
"latte/latte": "^2.3.0",
25+
"tracy/tracy": "^2.3.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"Arachne\\Codeception\\": "src"
30+
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Tests\\Integration\\": "tests/integration/src"
35+
}
36+
}
3937
}

docs/index.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Documentation
2+
====
3+
4+
Arachne/Codeception is here to help you with Integration and [Functional Tests](http://codeception.com/docs/04-FunctionalTests) for your Nette application.
5+
6+
NetteDIModule
7+
----
8+
9+
When you want to write an integration test to make sure that some services work well together you need to create the DI container first.
10+
11+
```yml
12+
# /tests/integration.suite.yml
13+
error_level: "E_ALL"
14+
class_name: IntegrationSuiteTester
15+
modules:
16+
enabled:
17+
- Arachne\Codeception\Module\NetteDIModule:
18+
tempDir: ../_temp/integration
19+
configFiles:
20+
- config/config.neon
21+
# Log directory for Tracy.
22+
# logDir: ../_log
23+
# Debug mode.
24+
# debugMode: true
25+
# Sometimes you might want to override the default Nette\Configurator with your own to get rid of the default extensions.
26+
# configurator: Arachne\Bootstrap\Configurator
27+
```
28+
29+
```
30+
# /tests/integration/config/config.neon
31+
services:
32+
- MyService
33+
```
34+
35+
```php
36+
# /tests/integration/src/MyServiceTest.php
37+
use Codeception\Test\Unit;
38+
class MyServiceTest extends Unit
39+
{
40+
public function testMyService()
41+
{
42+
// Here you can override the configFiles from integration.suite.yml if needed.
43+
// $this->tester->useConfigFiles(['config/another-config.neon']);
44+
$this->assertInstanceOf(MyService::class, $this->tester->grabService(MyService::class));
45+
}
46+
}
47+
```
48+
49+
NetteApplicationModule
50+
----
51+
52+
In functional tests you want to emulate the HTTP request and run `Nette\Application\Application` to handle it.
53+
54+
Unfortunately Nette framework has some downsides like the fact that Request and Response are registered as services in the DI Container. For this reason the NetteApplicationModule requires `Arachne\Codeception\DI\CodeceptionExtension` to override the default implementations. **Beware that this is meant for the functional tests only. Do NOT register the extension outside of tests.**
55+
56+
```
57+
# /tests/functional.suite.yml
58+
error_level: "E_ALL"
59+
class_name: FunctionalSuiteTester
60+
modules:
61+
enabled:
62+
- Arachne\Codeception\Module\NetteApplicationModule
63+
- Arachne\Codeception\Module\NetteDIModule:
64+
tempDir: ../_temp/functional
65+
configFiles:
66+
# Your application config file.
67+
- ../../app/config/config.neon
68+
# Additional config file only to add Arachne\Codeception\DI\HttpExtension.
69+
- config/config.neon
70+
```
71+
72+
```
73+
# /tests/functional/config/config.neon
74+
extensions:
75+
codeception: Arachne\Codeception\DI\HttpExtension
76+
```
77+
78+
```php
79+
# /tests/functional/src/HomepageTest.php
80+
use Codeception\Test\Unit;
81+
class HomepageTest extends Unit
82+
{
83+
public function testHomepage()
84+
{
85+
// Create http request and run Nette\Application\Application. See Arachne\Codeception\Connector\NetteConnector for details.
86+
$this->tester->amOnPage('/');
87+
// Assert that the response is what you expect.
88+
$this->tester->seeResponseCodeIs(200);
89+
$this->tester->see('Hello World!', 'h1');
90+
}
91+
}
92+
```

0 commit comments

Comments
 (0)