Skip to content

Commit 971a72b

Browse files
oliverkleeSam Tuke
authored andcommitted
[FEATURE] Integration tests for the dev and test environment (#44)
1 parent 27341b8 commit 971a72b

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ script:
6868
echo "Running the integration tests";
6969
vendor/bin/phpunit -c Configuration/PHPUnit/phpunit.xml Tests/Integration/;
7070
71+
- >
72+
echo;
73+
echo "Running the system tests";
74+
vendor/bin/phpunit -c Configuration/PHPUnit/phpunit.xml Tests/System/;
75+
7176
- >
7277
echo;
7378
echo "Running the static analysis";
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace PhpList\WebFrontend\Tests\System\ApplicationBundle;
5+
6+
use GuzzleHttp\Client;
7+
use PhpList\PhpList4\TestingSupport\Traits\SymfonyServerTrait;
8+
use PHPUnit\Framework\TestCase;
9+
10+
/**
11+
* Testcase.
12+
*
13+
* @author Oliver Klee <[email protected]>
14+
*/
15+
class PhpListApplicationBundleTest extends TestCase
16+
{
17+
use SymfonyServerTrait;
18+
19+
/**
20+
* @var Client
21+
*/
22+
private $httpClient = null;
23+
24+
protected function setUp()
25+
{
26+
$this->httpClient = new Client();
27+
}
28+
29+
protected function tearDown()
30+
{
31+
$this->stopSymfonyServer();
32+
}
33+
34+
/**
35+
* @return string[][]
36+
*/
37+
public function environmentDataProvider(): array
38+
{
39+
return [
40+
'test' => ['test'],
41+
'dev' => ['dev'],
42+
];
43+
}
44+
45+
/**
46+
* @test
47+
* @param string $environment
48+
* @dataProvider environmentDataProvider
49+
*/
50+
public function homepageReturnsSuccess(string $environment)
51+
{
52+
$this->startSymfonyServer($environment);
53+
54+
$response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]);
55+
56+
self::assertSame(200, $response->getStatusCode());
57+
}
58+
59+
/**
60+
* @test
61+
* @param string $environment
62+
* @dataProvider environmentDataProvider
63+
*/
64+
public function homepageReturnsContent(string $environment)
65+
{
66+
$this->startSymfonyServer($environment);
67+
68+
$response = $this->httpClient->get('/', ['base_uri' => $this->getBaseUrl()]);
69+
70+
self::assertNotEmpty($response->getBody()->getContents());
71+
}
72+
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
},
3333
"require-dev": {
3434
"phpunit/phpunit": "^6.5.0",
35+
"guzzlehttp/guzzle": "^6.3.0",
3536
"squizlabs/php_codesniffer": "^3.2.0",
3637
"phpstan/phpstan": "^0.7.0",
3738
"nette/caching": "^2.5.0 || ^3.0.0",

0 commit comments

Comments
 (0)