Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ jobs:
uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main
with:
scenarii: 20
tags: ci
coverage:
uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main
secrets: inherit
with:
tags: ci
psalm:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"require-dev": {
"innmind/static-analysis": "~1.3",
"innmind/coding-standard": "~2.0",
"innmind/black-box": "~6.5"
"innmind/black-box": "~6.12"
}
}
19 changes: 18 additions & 1 deletion tests/CircuitBreakerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
Period,
};
use Innmind\Immutable\Either;
use Innmind\BlackBox\PHPUnit\Framework\TestCase;
use Innmind\BlackBox\PHPUnit\Framework\{
TestCase,
Attributes\Group,
};

class CircuitBreakerTest extends TestCase
{
#[Group('local')]
#[Group('ci')]
public function testDoesntOpenCircuitOnSuccessfulResponse()
{
$request = Request::of(
Expand All @@ -51,6 +56,8 @@ public function testDoesntOpenCircuitOnSuccessfulResponse()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntOpenCircuitOnRedirectionResponse()
{
$request = Request::of(
Expand All @@ -74,6 +81,8 @@ public function testDoesntOpenCircuitOnRedirectionResponse()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntOpenCircuitOnClientErrorResponse()
{
$request = Request::of(
Expand All @@ -97,6 +106,8 @@ public function testDoesntOpenCircuitOnClientErrorResponse()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testOpenCircuitOnServerError()
{
$request = Request::of(
Expand Down Expand Up @@ -125,6 +136,8 @@ public function testOpenCircuitOnServerError()
));
}

#[Group('local')]
#[Group('ci')]
public function testOpenCircuitOnConnectionFailure()
{
$request = Request::of(
Expand All @@ -149,6 +162,8 @@ public function testOpenCircuitOnConnectionFailure()
));
}

#[Group('local')]
#[Group('ci')]
public function testOpenCircuitOnlyForTheDomainThatFailed()
{
$request1 = Request::of(
Expand Down Expand Up @@ -185,6 +200,8 @@ public function testOpenCircuitOnlyForTheDomainThatFailed()
$this->assertEquals($expected2, $fulfill($request2));
}

#[Group('local')]
#[Group('ci')]
public function testRecloseTheCircuitAfterTheSpecifiedDelay()
{
$request = Request::of(
Expand Down
9 changes: 8 additions & 1 deletion tests/ClientErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
};
use Innmind\Url\Url;
use Innmind\Immutable\Sequence;
use Innmind\BlackBox\PHPUnit\Framework\TestCase;
use Innmind\BlackBox\PHPUnit\Framework\{
TestCase,
Attributes\Group,
};

class ClientErrorTest extends TestCase
{
#[Group('local')]
#[Group('ci')]
public function testAcceptClientErrorfulResponses()
{
$_ = Sequence::of(...StatusCode::cases())
Expand All @@ -38,6 +43,8 @@ public function testAcceptClientErrorfulResponses()
});
}

#[Group('local')]
#[Group('ci')]
public function testRejectOtherKindOfResponse()
{
$_ = Sequence::of(...StatusCode::cases())
Expand Down
32 changes: 32 additions & 0 deletions tests/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
};
use Innmind\BlackBox\{
PHPUnit\Framework\TestCase,
PHPUnit\Framework\Attributes\Group,
PHPUnit\BlackBox,
Set,
};
Expand All @@ -58,6 +59,8 @@ public function setUp(): void
$this->curl = Transport::curl(Clock::live());
}

#[Group('local')]
#[Group('ci')]
public function testOkResponse()
{
$success = ($this->curl)(Request::of(
Expand All @@ -83,6 +86,8 @@ public function testOkResponse()
);
}

#[Group('local')]
#[Group('ci')]
public function testRedirection()
{
$redirection = ($this->curl)(Request::of(
Expand All @@ -109,6 +114,8 @@ public function testRedirection()
);
}

#[Group('local')]
#[Group('ci')]
public function testClientError()
{
$error = ($this->curl)(Request::of(
Expand All @@ -135,6 +142,8 @@ public function testClientError()
);
}

#[Group('local')]
#[Group('ci')]
public function testFailure()
{
$error = ($this->curl)($request = Request::of(
Expand All @@ -157,6 +166,8 @@ public function testFailure()
);
}

#[Group('local')]
#[Group('ci')]
public function testResponseBody()
{
$success = ($this->curl)(Request::of(
Expand Down Expand Up @@ -208,6 +219,8 @@ public function testResponseBody()
);
}

#[Group('local')]
#[Group('ci')]
public function testHead()
{
$success = ($this->curl)(Request::of(
Expand All @@ -227,6 +240,8 @@ public function testHead()
);
}

#[Group('local')]
#[Group('ci')]
public function testPost(): BlackBox\Proof
{
return $this
Expand Down Expand Up @@ -268,6 +283,8 @@ public function testPost(): BlackBox\Proof
});
}

#[Group('local')]
#[Group('ci')]
public function testPostLargeContent()
{
// The file is a bit more than 2Mo, so if everything was kept in memory
Expand Down Expand Up @@ -304,6 +321,8 @@ public function testPostLargeContent()
->megaBytes(3);
}

#[Group('local')]
#[Group('ci')]
public function testMinorVersionOfProtocolMayNotBePresent()
{
// Packagist respond with HTTP/2 instead of HTTP/2.0
Expand All @@ -320,6 +339,8 @@ public function testMinorVersionOfProtocolMayNotBePresent()
$this->assertSame(ProtocolVersion::v20, $success->protocolVersion());
}

#[Group('local')]
#[Group('ci')]
public function testConcurrency()
{
$request = Request::of(
Expand Down Expand Up @@ -355,6 +376,8 @@ public function testConcurrency()
->seconds((int) \ceil(2 * $forOneRequest));
}

#[Group('local')]
#[Group('ci')]
public function testMaxConcurrency()
{
$curl = $this->curl->map(static fn($config) => $config->limitConcurrencyTo(1));
Expand Down Expand Up @@ -395,6 +418,8 @@ public function testMaxConcurrency()
->seconds((int) (2 * $forOneRequest));
}

#[Group('local')]
#[Group('ci')]
public function testHeartbeat()
{
$heartbeat = 0;
Expand All @@ -419,6 +444,8 @@ static function() use (&$heartbeat) {
$this->assertGreaterThan(1, $heartbeat);
}

#[Group('local')]
#[Group('ci')]
public function testOutOfOrderUnwrapWithMaxConcurrency()
{
$curl = $this->curl->map(static fn($config) => $config->limitConcurrencyTo(2));
Expand All @@ -444,6 +471,8 @@ public function testOutOfOrderUnwrapWithMaxConcurrency()
);
}

#[Group('local')]
#[Group('ci')]
public function testSubsequentRequestsAreCalledCorrectlyInsideFlatMaps()
{
$curl = $this->curl->map(static fn($config) => $config->limitConcurrencyTo(2));
Expand Down Expand Up @@ -471,6 +500,8 @@ public function testSubsequentRequestsAreCalledCorrectlyInsideFlatMaps()
);
}

#[Group('local')]
#[Group('ci')]
public function testReleaseResources()
{
$initialCount = \count(\get_resources('stream'));
Expand All @@ -496,6 +527,7 @@ public function testReleaseResources()
$this->assertSame($initialCount, \count(\get_resources('stream')));
}

#[Group('local')]
public function testTimeout()
{
foreach (['bin', 'bun'] as $server) {
Expand Down
27 changes: 26 additions & 1 deletion tests/ExponentialBackoffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
Attempt,
SideEffect,
};
use Innmind\BlackBox\PHPUnit\Framework\TestCase;
use Innmind\BlackBox\PHPUnit\Framework\{
TestCase,
Attributes\Group,
};

class ExponentialBackoffTest extends TestCase
{
#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenInformationResponseOnFirstCall()
{
$request = Request::of(
Expand All @@ -56,6 +61,8 @@ public function testDoesntRetryWhenInformationResponseOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenSuccessfulResponseOnFirstCall()
{
$request = Request::of(
Expand All @@ -77,6 +84,8 @@ public function testDoesntRetryWhenSuccessfulResponseOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenRedirectionResponseOnFirstCall()
{
$request = Request::of(
Expand All @@ -98,6 +107,8 @@ public function testDoesntRetryWhenRedirectionResponseOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenClientErrorResponseOnFirstCall()
{
$request = Request::of(
Expand All @@ -119,6 +130,8 @@ public function testDoesntRetryWhenClientErrorResponseOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenMalformedResponseOnFirstCall()
{
$request = Request::of(
Expand All @@ -136,6 +149,8 @@ public function testDoesntRetryWhenMalformedResponseOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testDoesntRetryWhenFailureOnFirstCall()
{
$request = Request::of(
Expand All @@ -153,6 +168,8 @@ public function testDoesntRetryWhenFailureOnFirstCall()
$this->assertEquals($expected, $fulfill($request));
}

#[Group('local')]
#[Group('ci')]
public function testRetryWhileThereIsStillATooManyRequestsError()
{
$request = Request::of(
Expand Down Expand Up @@ -195,6 +212,8 @@ public function testRetryWhileThereIsStillATooManyRequestsError()
$this->assertSame(12, $calls);
}

#[Group('local')]
#[Group('ci')]
public function testRetryWhileThereIsStillAServerError()
{
$request = Request::of(
Expand Down Expand Up @@ -237,6 +256,8 @@ public function testRetryWhileThereIsStillAServerError()
$this->assertSame(12, $calls);
}

#[Group('local')]
#[Group('ci')]
public function testRetryWhileThereIsStillAConnectionFailure()
{
$request = Request::of(
Expand Down Expand Up @@ -275,6 +296,8 @@ public function testRetryWhileThereIsStillAConnectionFailure()
$this->assertSame(12, $calls);
}

#[Group('local')]
#[Group('ci')]
public function testStopRetryingWhenNoLongerReceivingAServerError()
{
$request = Request::of(
Expand Down Expand Up @@ -317,6 +340,8 @@ public function testStopRetryingWhenNoLongerReceivingAServerError()
$this->assertSame(2, $calls);
}

#[Group('local')]
#[Group('ci')]
public function testByDefaultRetriesFiveTimesByUsingAPowerOfE()
{
$request = Request::of(
Expand Down
Loading
Loading