Skip to content

Commit

Permalink
Update PHPUnit.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkhamez committed Jan 26, 2024
1 parent 62218ba commit ef57243
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 319 deletions.
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.env
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.result.cache
/.phpunit.cache
/var/cache/*
!/var/cache/.gitkeep
/var/logs/*
Expand Down
2 changes: 1 addition & 1 deletion backend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"friendsofphp/php-cs-fixer": "^3.0",
"phan/phan": "^5.2",
"phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.4",
"web-token/jwt-key-mgmt": "^3.2"
},
Expand Down
513 changes: 232 additions & 281 deletions backend/composer.lock

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions backend/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?xml version="1.0"?>
<!DOCTYPE xml>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<testsuites>
<testsuite name="Neucore">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory>./src/Migrations</directory>
</exclude>
</coverage>
<logging/>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Neucore">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory>./src/Migrations</directory>
</exclude>
</source>
</phpunit>
8 changes: 4 additions & 4 deletions backend/tests/Functional/Command/SendInvalidTokenMailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testExecuteNotActive()
$this->assertStringEndsWith('Started "send-invalid-token-mail"', $actual[0]);
$this->assertStringEndsWith(' Mail is deactivated.', $actual[1]);
$this->assertStringEndsWith('Finished "send-invalid-token-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteMisconfiguration()
Expand Down Expand Up @@ -79,7 +79,7 @@ public function testExecuteMisconfiguration()
$this->assertStringEndsWith('Started "send-invalid-token-mail"', $actual[0]);
$this->assertStringEndsWith(' Missing character that can send mails or missing token data.', $actual[1]);
$this->assertStringEndsWith('Finished "send-invalid-token-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteRequestException()
Expand All @@ -106,7 +106,7 @@ public function testExecuteRequestException()
$actual[1]
);
$this->assertStringEndsWith('Finished "send-invalid-token-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);

$this->assertSame(0, count($log->getHandler()->getRecords()));

Expand All @@ -130,7 +130,7 @@ public function testExecute()
$this->assertStringEndsWith('Started "send-invalid-token-mail"', $actual[0]);
$this->assertStringEndsWith(' Invalid token mail sent to 30', $actual[1]);
$this->assertStringEndsWith('Finished "send-invalid-token-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);

$this->om->clear();
$player = $this->repoFactory->getPlayerRepository()->find($this->playerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testExecuteNotActive()
$this->assertStringEndsWith('Started "send-missing-character-mail"', $actual[0]);
$this->assertStringEndsWith(' Mail is deactivated.', $actual[1]);
$this->assertStringEndsWith('Finished "send-missing-character-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteInvalidConfig()
Expand All @@ -64,7 +64,7 @@ public function testExecuteInvalidConfig()
$this->assertStringEndsWith('Started "send-missing-character-mail"', $actual[0]);
$this->assertStringEndsWith(' Invalid config.', $actual[1]);
$this->assertStringEndsWith('Finished "send-missing-character-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteMisconfiguration()
Expand All @@ -78,7 +78,7 @@ public function testExecuteMisconfiguration()
$this->assertStringEndsWith('Started "send-missing-character-mail"', $actual[0]);
$this->assertStringEndsWith(' Missing subject or body text.', $actual[1]);
$this->assertStringEndsWith('Finished "send-missing-character-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteRequestException()
Expand All @@ -105,7 +105,7 @@ public function testExecuteRequestException()
$actual[1]
);
$this->assertStringEndsWith('Finished "send-missing-character-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);

$this->assertSame(0, count($log->getHandler()->getRecords()));

Expand All @@ -129,7 +129,7 @@ public function testExecute()
$this->assertStringEndsWith('Started "send-missing-character-mail"', $actual[0]);
$this->assertStringEndsWith(' Missing character mail sent to 104', $actual[1]);
$this->assertStringEndsWith('Finished "send-missing-character-mail"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);

$this->om->clear();
$member4 = $this->repoFactory->getCorporationMemberRepository()->find(104);
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/Functional/Command/UpdateCharactersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testExecuteError()
$this->assertStringEndsWith('Started "update-chars"', $actual[0]);
$this->assertStringEndsWith(' Character 1: update NOK', $actual[1]);
$this->assertStringEndsWith('Finished "update-chars"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteOk()
Expand Down Expand Up @@ -81,7 +81,7 @@ public function testExecuteOk()
$this->assertStringEndsWith('Started "update-chars"', $actual[0]);
$this->assertStringEndsWith(' Characters 3,6: update OK', $actual[1]);
$this->assertStringEndsWith('Finished "update-chars"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);

// read result
$this->om->clear();
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/Functional/Command/UpdateCorporationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testExecuteError()
$this->assertStringEndsWith('Started "update-corporations"', $actual[0]);
$this->assertStringEndsWith(' Corporation 101: ' . UpdateCorporations::UPDATE_NOK, $actual[1]);
$this->assertStringEndsWith('Finished "update-corporations"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteInvalidCorp()
Expand All @@ -66,7 +66,7 @@ public function testExecuteInvalidCorp()
$this->assertStringEndsWith('Started "update-corporations"', $actual[0]);
$this->assertStringEndsWith(' Corporation 0: ' . UpdateCorporations::UPDATE_NOK, $actual[1]);
$this->assertStringEndsWith('Finished "update-corporations"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteOk()
Expand All @@ -90,7 +90,7 @@ public function testExecuteOk()
$this->assertStringEndsWith(' Corporation 101: ' . UpdateCorporations::UPDATE_OK, $actual[1]);
$this->assertStringEndsWith(' Alliance 212: ' . UpdateCorporations::UPDATE_OK, $actual[2]);
$this->assertStringEndsWith('Finished "update-corporations"', $actual[3]);
$this->assertStringEndsWith('', $actual[4]);
$this->assertSame('', $actual[4]);

// read result
$this->om->clear();
Expand Down
10 changes: 5 additions & 5 deletions backend/tests/Functional/Command/UpdateMemberTrackingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testExecuteErrorCorp()
$this->assertStringEndsWith('Started "update-member-tracking"', $actual[0]);
$this->assertStringEndsWith(' Corporation not found for Director', $actual[1]);
$this->assertStringEndsWith('Finished "update-member-tracking"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteErrorToken()
Expand All @@ -64,7 +64,7 @@ public function testExecuteErrorToken()
$this->assertStringEndsWith('Started "update-member-tracking"', $actual[0]);
$this->assertStringEndsWith(' Error refreshing token for Director', $actual[1]);
$this->assertStringEndsWith('Finished "update-member-tracking"', $actual[2]);
$this->assertStringEndsWith('', $actual[3]);
$this->assertSame('', $actual[3]);
}

public function testExecuteErrorData()
Expand All @@ -84,7 +84,7 @@ public function testExecuteErrorData()
$this->assertStringEndsWith(' Start updating Corporation', $actual[1]);
$this->assertStringEndsWith(' Error getting member tracking data from ESI for Director', $actual[2]);
$this->assertStringEndsWith('Finished "update-member-tracking"', $actual[3]);
$this->assertStringEndsWith('', $actual[4]);
$this->assertSame('', $actual[4]);
}

public function testExecuteSuccess()
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testExecuteSuccess()
$this->assertStringEndsWith(' Start updating Corp 2', $actual[5]);
$this->assertStringEndsWith(' Updated tracking data for 0 members of corporation 100202', $actual[6]);
$this->assertStringEndsWith('Finished "update-member-tracking"', $actual[7]);
$this->assertStringEndsWith('', $actual[8]);
$this->assertSame('', $actual[8]);

$this->om->clear();
$corps = (new RepositoryFactory($this->om))->getCorporationRepository()->findBy([]);
Expand All @@ -122,7 +122,7 @@ public function testExecuteSuccess()
$this->assertNotNull($corps[1]->getTrackingLastUpdate());
}

private function addData(bool $noCorporation = false, bool $expiredToken = false, bool $addSecond = true)
private function addData(bool $noCorporation = false, bool $expiredToken = false, bool $addSecond = true): void
{
$eveLogin = (new EveLogin())->setName(EveLogin::NAME_TRACKING);
$corporation1 = (new Corporation())->setId(100200)->setName('Corporation');
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/Functional/Command/UpdatePlayerGroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UpdatePlayerGroupsTest extends ConsoleTestCase
{
public function testExecute()
{
// setup
// setup
$h = new Helper();
$h->emptyDb();
$h->addRoles([Role::TRACKING, Role::WATCHLIST, Role::WATCHLIST_MANAGER]);
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testExecute()
$this->assertStringEndsWith(' Account '.$p1->getId().' groups updated', $actual[1]);
$this->assertStringEndsWith(' Account '.$p2->getId().' groups updated', $actual[2]);
$this->assertStringEndsWith('Finished "update-player-groups"', $actual[3]);
$this->assertStringEndsWith('', $actual[4]);
$this->assertSame('', $actual[4]);

# read result
$actual = (new RepositoryFactory($om))->getPlayerRepository()->findBy([]);
Expand Down
4 changes: 4 additions & 0 deletions backend/tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Unit;

use PHPUnit\Framework\MockObject\Exception;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Interfaces\RouteInterface;
use Slim\Interfaces\RouteParserInterface;
Expand All @@ -11,6 +12,9 @@

class TestCase extends \PHPUnit\Framework\TestCase
{
/**
* @throws Exception
*/
protected function createRequestWithRoute(string $method = 'GET', string $path = null): ServerRequestInterface
{
$routeParser = $this->createMock(RouteParserInterface::class);
Expand Down

0 comments on commit ef57243

Please sign in to comment.