Skip to content

Commit 51ae7fb

Browse files
authored
Replace "Yii Testing" to "Yii HTTP Runner" usage (#353)
1 parent 3bff0c2 commit 51ae7fb

File tree

5 files changed

+52
-38
lines changed

5 files changed

+52
-38
lines changed

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@
7878
"yiisoft/translator-message-php": "^1.1",
7979
"yiisoft/view": "^12.0",
8080
"yiisoft/yii-console": "^2.0",
81-
"yiisoft/yii-debug": "dev-master|dev-php80",
81+
"yiisoft/yii-debug": "dev-master",
8282
"yiisoft/yii-event": "^2.0",
8383
"yiisoft/yii-http": "^1.0",
8484
"yiisoft/yii-middleware": "^1.0",
8585
"yiisoft/yii-runner-console": "^2.0",
86-
"yiisoft/yii-runner-http": "^3.0",
86+
"yiisoft/yii-runner-http": "^3.2",
8787
"yiisoft/yii-view-renderer": "^7.1"
8888
},
8989
"require-dev": {
@@ -100,8 +100,7 @@
100100
"vimeo/psalm": "^5.20",
101101
"yiisoft/yii-debug-api": "3.0.x-dev",
102102
"yiisoft/yii-debug-viewer": "^3.0@dev",
103-
"yiisoft/yii-gii": "dev-master",
104-
"yiisoft/yii-testing": "dev-master"
103+
"yiisoft/yii-gii": "dev-master"
105104
},
106105
"autoload": {
107106
"psr-4": {

tests/Functional.suite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
actor: FunctionalTester
22
modules:
3-
enabled:
4-
step_decorators: ~
3+
enabled:
4+
step_decorators: ~
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests\Functional;
6+
7+
use App\Tests\Support\FunctionalTester;
8+
use HttpSoft\Message\ServerRequest;
9+
10+
use function PHPUnit\Framework\assertStringContainsString;
11+
12+
final class SiteControllerCest
13+
{
14+
public function testGetIndex(FunctionalTester $tester): void
15+
{
16+
$response = $tester->sendRequest(
17+
new ServerRequest(uri: '/'),
18+
);
19+
20+
assertStringContainsString(
21+
'Don\'t forget to check the guide',
22+
$response->getBody()->getContents(),
23+
);
24+
}
25+
}

tests/Functional/SiteControllerTest.php

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

tests/Support/FunctionalTester.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
namespace App\Tests\Support;
66

7+
use Psr\Http\Message\ResponseInterface;
8+
use Psr\Http\Message\ServerRequestInterface;
9+
use Yiisoft\Yii\Runner\Http\HttpApplicationRunner;
10+
11+
use function dirname;
12+
713
/**
814
* Inherited Methods
915
*
@@ -27,4 +33,20 @@ class FunctionalTester extends \Codeception\Actor
2733
/**
2834
* Define custom actions here
2935
*/
36+
public function sendRequest(ServerRequestInterface $request): ResponseInterface
37+
{
38+
$runner = new HttpApplicationRunner(
39+
rootPath: dirname(__DIR__, 2),
40+
environment: $_ENV['YII_ENV'],
41+
);
42+
43+
$response = $runner->runAndGetResponse($request);
44+
45+
$body = $response->getBody();
46+
if ($body->isSeekable()) {
47+
$body->rewind();
48+
}
49+
50+
return $response;
51+
}
3052
}

0 commit comments

Comments
 (0)