Skip to content

Commit

Permalink
Update phpunit
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Jan 9, 2024
1 parent 38bca94 commit 4135095
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "lowest"
- "highest"
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
},
"require-dev": {
"amphp/dns": "^2",
"amphp/http-client": "^v5.0.0-beta.8",
"amphp/http": "^2.1",
"amphp/http-client": "^5",
"amphp/process": "^2",
"mockery/mockery": "^1.5",
"phpunit/php-code-coverage": "^9",
"phpunit/phpunit": "^9"
"phpunit/php-code-coverage": "^10",
"phpunit/phpunit": "^10.5",
"seec/phpunit-consecutive-params": "^1.1"
},
"minimum-stability": "beta",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Ostrolucky\\Stdinho\\": "src"
Expand Down
14 changes: 7 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
<coverage>
<include>
<file>bin/stdinho</file>
<directory>src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="stdinho">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<file>bin/stdinho</file>
<directory>src</directory>
</include>
</source>
</phpunit>
5 changes: 4 additions & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use SEEC\PhpUnit\Helper\ConsecutiveParams;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use function Amp\async;

class IntegrationTest extends TestCase
{
use ConsecutiveParams;

public function testBufferOverflow(): void
{
$buffererInput = $this->createMock(ReadableStream::class);
Expand Down Expand Up @@ -54,7 +57,7 @@ public function testBufferOverflow(): void
$socket
->expects(static::exactly(4))
->method('write')
->withConsecutive([Assert::stringContains('HTTP/1.1 200 OK')], [$foo], [$bar], [$baz])
->with(...$this->withConsecutive([Assert::stringContains('HTTP/1.1 200 OK')], [$foo], [$bar], [$baz]))
;

$logger->expects(self::once())->method('warning')->with(self::stringStartsWith('Max buffer size reached'));
Expand Down
15 changes: 7 additions & 8 deletions tests/ResponderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
use Amp\ByteStream\ReadableStream;
use Amp\ByteStream\WritableResourceStream;
use Amp\DeferredFuture;
use Amp\Future;
use Psr\Log\LoggerInterface;
use function Amp\Promise\wait;
use Amp\Socket\Socket;
use Amp\Socket\SocketAddress;
use Ostrolucky\Stdinho\Bufferer\ResolvedBufferer;
use Ostrolucky\Stdinho\Responder;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use SEEC\PhpUnit\Helper\ConsecutiveParams;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\ConsoleSectionOutput;

class ResponderTest extends TestCase
{
use ConsecutiveParams;

public function testResponderHandlesClientAbruptDisconnect(): void
{
$responder = new Responder(
Expand All @@ -31,10 +32,10 @@ public function testResponderHandlesClientAbruptDisconnect(): void
$this->createMock(ReadableStream::class),
new DeferredFuture()
);
$logger->expects(self::exactly(2))->method('debug')->withConsecutive(
$logger->expects(self::exactly(2))->method('debug')->with(...$this->withConsecutive(
[self::stringStartsWith('Accepted connection')],
[self::stringContains('aborted download')],
);
));
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$outputFormatter->method('format')->willReturn('');
Expand All @@ -46,9 +47,7 @@ public function testResponderHandlesClientAbruptDisconnect(): void

$socket->method('getRemoteAddress')->willReturn($this->createMock(SocketAddress::class));
$socket->method('read')->willReturn('');
$socket->method('write')->willReturnCallback(function(string $data) use ($writer) {
return $writer->write($data);
});
$socket->method('write')->willReturnCallback(fn(string $data) => $writer->write($data));

fclose($resource);

Expand Down

0 comments on commit 4135095

Please sign in to comment.