Skip to content

Commit

Permalink
chore: upgrade phpunit to 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ramunasd committed Mar 23, 2024
1 parent 01b47d3 commit a25dda6
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 377 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.5",
"symfony/browser-kit": "^5.4"
},
"autoload": {
Expand Down
619 changes: 286 additions & 333 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ monolog:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.log"
max_files: 30
docker:
stderr:
type: stream
path: "php://stderr"
2 changes: 2 additions & 0 deletions config/parameters.test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
parameters:
log.handler: 'stderr'
log.level: 'error'
satis_filename: "vfs://root/satis.json"
satis_log_path: "vfs://root/satis/"
admin.auth: false
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" cacheResultFile="var/.phpunit.result.cache">
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<php>
<env name="KERNEL_CLASS" value="TestKernel"/>
<env name="APP_ENV" value="test" force="true"/>
Expand All @@ -16,4 +11,9 @@
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
4 changes: 0 additions & 4 deletions src/Playbloom/Satisfy/Webhook/GithubWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public function getResponse(Request $request): Response

$callback = function () use ($repository) {
echo 'OK';
if (!isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
ignore_user_abort(true);
Response::closeOutputBuffers(0, true);
}
$this->handle($repository);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testConfigIsMatchingSatisSchema($configFilename): void
$this->assertJsonFileEqualsJsonFile($configFilename, $this->config->url());
}

public function configFileProvider(): array
public static function configFileProvider(): array
{
return [
[__DIR__ . '/../../../fixtures/satis-minimal.json'],
Expand Down
12 changes: 6 additions & 6 deletions tests/Playbloom/Satisfy/Webhook/BitbucketWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ public function testInvalidRequestMustThrowException($request): void
$controller->bitbucketAction($request);
}

public function invalidRequestProvider(): \Generator
public static function invalidRequestProvider(): \Generator
{
// invalid IP
yield [$this->createRequest('', '1.1.1.1')];
yield [self::createRequest('', '1.1.1.1')];

// valid IP, missing content
yield [Request::create('')];

// valid IP, missing required param
$content = ['repository' => ['full_name' => '']];
yield [$this->createRequest($content)];
yield [self::createRequest($content)];

// valid content, unknown repository url
$content = ['repository' => ['full_name' => 'test/test']];
yield [$this->createRequest($content)];
yield [self::createRequest($content)];
}

public function testValidRequestMustTriggerBuild(): void
Expand Down Expand Up @@ -87,15 +87,15 @@ public function testValidRequestMustTriggerBuild(): void
->getRootPath()
->willReturn($rootPath);

$request = $this->createRequest(['repository' => ['full_name' => 'test/test']]);
$request = self::createRequest(['repository' => ['full_name' => 'test/test']]);
/** @var BitbucketWebhook $webhook */
$webhook = $container->get(BitbucketWebhook::class);
$response = $webhook->getResponse($request);

$this->assertEquals(0, $response->getContent());
}

protected function createRequest($content, string $ipAddress = '127.0.0.1'): Request
protected static function createRequest($content, string $ipAddress = '127.0.0.1'): Request
{
return Request::create('', 'GET', [], [], [], ['REMOTE_ADDR' => $ipAddress], json_encode($content));
}
Expand Down
5 changes: 2 additions & 3 deletions tests/Playbloom/Satisfy/Webhook/DevOpsWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Tests\Playbloom\Satisfy\Webhook;

use Generator;
use PHPUnit\Framework\TestCase;
use Playbloom\Satisfy\Event\BuildEvent;
use Playbloom\Satisfy\Model\Repository;
Expand Down Expand Up @@ -66,7 +65,7 @@ function ($args) {
self::assertEquals(0, $response->getContent());
}

public function testInvalidTokenRequest()
public function testInvalidTokenRequest(): void
{
$manager = $this->getManagerMock();
$manager
Expand All @@ -89,7 +88,7 @@ public function testInvalidTokenRequest()
self::assertEquals(Response::HTTP_BAD_REQUEST, $response->getStatusCode());
}

public function invalidRequestProvider(): \Generator
public static function invalidRequestProvider(): \Generator
{
yield [self::createRequest([], '')];

Expand Down
16 changes: 8 additions & 8 deletions tests/Playbloom/Satisfy/Webhook/GithubWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public function testInvalidRequest($request): void
$handler->getResponse($request);
}

public function invalidRequestProvider(): \Generator
public static function invalidRequestProvider(): \Generator
{
yield [$this->createRequest([], '')];
yield [self::createRequest([], '')];

yield [$this->createRequest([])];
yield [self::createRequest([])];

yield [$this->createRequest(['repository' => []])];
yield [self::createRequest(['repository' => []])];
}

public function testValidRequest(): void
Expand All @@ -59,7 +59,7 @@ function ($args) {
)
->shouldBeCalledTimes(1);

$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/github-push.json'));
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/github-push.json'));
$handler = new GithubWebhook($manager->reveal(), $dispatcher->reveal());
$response = $handler->getResponse($request);

Expand All @@ -71,7 +71,7 @@ function ($args) {
$this->assertEquals('OK', $result);
}

public function testValidRequestWithRepoAutoAdd()
public function testValidRequestWithRepoAutoAdd(): void
{
$manager = $this->getManagerMock();
$manager
Expand All @@ -95,7 +95,7 @@ function ($args) {
)
->shouldBeCalledTimes(1);

$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/github-push.json'));
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/github-push.json'));
$handler = new GithubWebhook($manager->reveal(), $dispatcher->reveal());
$handler->setAutoAdd(true);
$handler->setAutoAddType('github');
Expand All @@ -109,7 +109,7 @@ function ($args) {
$this->assertEquals('OK', $result);
}

protected function createRequest($content, string $event = 'push'): Request
protected static function createRequest($content, string $event = 'push'): Request
{
if (!is_string($content)) {
$content = json_encode($content);
Expand Down
28 changes: 14 additions & 14 deletions tests/Playbloom/Satisfy/Webhook/GitlabWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function testInvalidRequest($request): void
$handler->getResponse($request);
}

public function invalidRequestProvider(): \Generator
public static function invalidRequestProvider(): \Generator
{
yield [$this->createRequest([], '')];
yield [self::createRequest([], '')];

yield [$this->createRequest([])];
yield [self::createRequest([])];

yield [$this->createRequest(['repository' => []])];
yield [self::createRequest(['repository' => []])];
}

public function testValidRequest(): void
Expand All @@ -60,7 +60,7 @@ function ($args) {
)
->shouldBeCalledTimes(1);

$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push.json'));
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push.json'));
$handler = new GitlabWebhook($manager->reveal(), $dispatcher->reveal());
$response = $handler->getResponse($request);

Expand Down Expand Up @@ -92,7 +92,7 @@ function ($args) {
)
->shouldBeCalledTimes(1);

$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push-nonexistant.json'));
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push-nonexistant.json'));
$handler = new GitlabWebhook($manager->reveal(), $dispatcher->reveal(), null, true);
$response = $handler->getResponse($request);

Expand Down Expand Up @@ -120,7 +120,7 @@ function ($args) {
)
->shouldBeCalledTimes(1);

$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push-deprecated.json'));
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push-deprecated.json'));
$handler = new GitlabWebhook($manager->reveal(), $dispatcher->reveal());
$response = $handler->getResponse($request);

Expand All @@ -142,7 +142,7 @@ public function testInvalidTokenRequest(): void

$this->expectException(BadRequestHttpException::class);
$this->expectExceptionMessage('Invalid Token');
$request = $this->createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push.json'), 'push', 'invalid-token');
$request = self::createRequest(file_get_contents(__DIR__ . '/../../../fixtures/gitlab-push.json'), 'push', 'invalid-token');
$handler = new GitlabWebhook($manager->reveal(), $dispatcher->reveal());
$response = $handler->getResponse($request);

Expand All @@ -152,7 +152,7 @@ public function testInvalidTokenRequest(): void
public function testAutoAddOnlyHttp(): void
{
$url = 'https://gitlab.com/example/nonexistant.git';
$request = $this->createRequest([
$request = self::createRequest([
'project' => [
'git_http_url' => $url,
],
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testAutoAddPreferSsh(): void
{
$httpUrl = 'https://gitlab.com/example/nonexistant.git';
$sshUrl = 'git@gitlab.com:example/nonexistant.git';
$request = $this->createRequest([
$request = self::createRequest([
'project' => [
'git_http_url' => $httpUrl,
'git_ssh_url' => $sshUrl,
Expand Down Expand Up @@ -215,7 +215,7 @@ public function testAutoAddPreferSsh(): void
public function testAutoAddPreferSshFallback(): void
{
$httpUrl = 'https://gitlab.com/example/nonexistant.git';
$request = $this->createRequest([
$request = self::createRequest([
'project' => [
'git_http_url' => $httpUrl,
],
Expand Down Expand Up @@ -243,7 +243,7 @@ public function testAutoAddPreferHttps(): void
{
$httpUrl = 'https://gitlab.com/example/nonexistant.git';
$sshUrl = 'git@gitlab.com:example/nonexistant.git';
$request = $this->createRequest([
$request = self::createRequest([
'project' => [
'git_http_url' => $httpUrl,
'git_ssh_url' => $sshUrl,
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testAutoAddPreferHttps(): void
public function testAutoAddPreferHttpsFallback(): void
{
$sshUrl = 'git@gitlab.com:example/nonexistant.git';
$request = $this->createRequest([
$request = self::createRequest([
'project' => [
'git_ssh_url' => $sshUrl,
],
Expand All @@ -299,7 +299,7 @@ public function testAutoAddPreferHttpsFallback(): void
$response = $handler->getResponse($request);
}

protected function createRequest($content, string $event = 'push', ?string $token = null): Request
protected static function createRequest($content, string $event = 'push', ?string $token = null): Request
{
if (!is_string($content)) {
$content = json_encode($content);
Expand Down

0 comments on commit a25dda6

Please sign in to comment.