Skip to content

Commit 4f95ca0

Browse files
committed
Fix tests on php-school/php-workshop 3
1 parent d5a5c48 commit 4f95ca0

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/Exercise/ConcernedAboutSeparation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PhpSchool\LearnYouPhp\Exercise;
44

55
use Faker\Generator;
6+
use PhpParser\Node\Stmt\Expression;
67
use PhpParser\Parser;
78
use PhpSchool\PhpWorkshop\Exercise\AbstractExercise;
89
use PhpSchool\PhpWorkshop\Exercise\CliExercise;
@@ -142,7 +143,7 @@ public function check(Input $input): ResultInterface
142143

143144
$include = null;
144145
foreach ($statements as $statement) {
145-
if ($statement instanceof Include_) {
146+
if ($statement instanceof Expression && $statement->expr instanceof Include_) {
146147
$include = $statement;
147148
break;
148149
}

src/Exercise/DependencyHeaven.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PhpSchool\LearnYouPhp\Exercise;
44

55
use Faker\Generator;
6+
use GuzzleHttp\Psr7\Request;
67
use PhpSchool\PhpWorkshop\Check\ComposerCheck;
78
use PhpSchool\PhpWorkshop\Exercise\AbstractExercise;
89
use PhpSchool\PhpWorkshop\Exercise\CgiExercise;
@@ -13,7 +14,7 @@
1314
use PhpSchool\PhpWorkshop\ExerciseDispatcher;
1415
use PhpSchool\PhpWorkshop\Solution\DirectorySolution;
1516
use PhpSchool\PhpWorkshop\Solution\SolutionInterface;
16-
use Zend\Diactoros\Request;
17+
use Psr\Http\Message\RequestInterface;
1718

1819
/**
1920
* Class DependencyHeaven
@@ -84,8 +85,7 @@ public function getRequests(): array
8485
*/
8586
private function newApiRequest(string $endpoint): RequestInterface
8687
{
87-
$request = (new Request($endpoint))
88-
->withMethod('POST')
88+
$request = (new Request('POST', $endpoint))
8989
->withHeader('Content-Type', 'application/x-www-form-urlencoded');
9090

9191
$request->getBody()->write(

src/Exercise/HttpJsonApi.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace PhpSchool\LearnYouPhp\Exercise;
44

5+
use GuzzleHttp\Psr7\Request;
56
use PhpSchool\PhpWorkshop\Exercise\AbstractExercise;
67
use PhpSchool\PhpWorkshop\Exercise\CgiExercise;
78
use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface;
89
use PhpSchool\PhpWorkshop\Exercise\ExerciseType;
910
use PhpSchool\PhpWorkshop\ExerciseCheck\CgiOutputExerciseCheck;
1011
use Psr\Http\Message\RequestInterface;
11-
use Zend\Diactoros\Request;
1212

1313
/**
1414
* Class HttpJsonApi
@@ -40,10 +40,8 @@ public function getRequests(): array
4040
{
4141
$url = 'http://www.time.com/api/%s?iso=%s';
4242
return [
43-
(new Request(sprintf($url, 'parsetime', urlencode((new \DateTime())->format(DATE_ISO8601)))))
44-
->withMethod('GET'),
45-
(new Request(sprintf($url, 'unixtime', urlencode((new \DateTime())->format(DATE_ISO8601)))))
46-
->withMethod('GET'),
43+
(new Request('GET', sprintf($url, 'parsetime', urlencode((new \DateTime())->format(DATE_ISO8601))))),
44+
(new Request('GET', sprintf($url, 'unixtime', urlencode((new \DateTime())->format(DATE_ISO8601)))))
4745
];
4846
}
4947

test/Exercise/TimeServerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PhpSchool\LearnYouPhpTest\Exercise;
44

55
use Colors\Color;
6-
use PhpSchool\CliMenu\Terminal\TerminalInterface;
76
use PhpSchool\LearnYouPhp\Exercise\TimeServer;
87
use PhpSchool\LearnYouPhp\TcpSocketFactory;
98
use PhpSchool\PhpWorkshop\Check\CheckRepository;
@@ -22,6 +21,7 @@
2221
use PhpSchool\PhpWorkshop\Result\Success;
2322
use PhpSchool\PhpWorkshop\ResultAggregator;
2423
use PhpSchool\PhpWorkshop\Solution\SolutionInterface;
24+
use PhpSchool\Terminal\Terminal;
2525
use PHPUnit\Framework\TestCase;
2626

2727
/**
@@ -121,7 +121,7 @@ public function testRun(): void
121121
{
122122
$color = new Color();
123123
$color->setForceStyle(true);
124-
$output = new StdOutput($color, $terminal = $this->createMock(TerminalInterface::class));
124+
$output = new StdOutput($color, $terminal = $this->createMock(Terminal::class));
125125

126126
$outputRegEx = "/\n";
127127
$outputRegEx .= '\[1m\[4mArguments\[0m\[0m';

0 commit comments

Comments
 (0)