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
10 changes: 9 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ jobs:
if: ${{ matrix.database == 'postgres' }}
uses: ankane/setup-postgres@v1

- name: Create worker databases - mysql
if: ${{ matrix.database == 'mysql' }}
run: for i in 1 2 3 4; do mysql -u root -e "CREATE DATABASE IF NOT EXISTS app$i;"; done

- name: Create worker databases - postgres
if: ${{ matrix.database == 'postgres' }}
run: for i in 1 2 3 4; do createdb "${POSTGRES_DB}$i"; done

- name: Set database config - ${{ matrix.database }}
run: php -r "copy('tests/Fixtures/Config/database.${{ matrix.database }}.php', 'tests/Fixtures/Config/database.config.php');"

Expand All @@ -118,4 +126,4 @@ jobs:
run: php ./tempest discovery:status

- name: Execute tests
run: php -d"error_reporting = E_ALL & ~E_DEPRECATED" -dmemory_limit=2G vendor/bin/phpunit
run: php -d"error_reporting = E_ALL & ~E_DEPRECATED" -dmemory_limit=2G vendor/bin/paratest --runner WrapperRunner --processes 4
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,17 @@
"Composer\\Config::disableProcessTimeout",
"@php -d memory_limit=2G vendor/bin/phpunit --display-warnings --display-skipped --display-deprecations --display-errors --display-notices"
],
"paratest": [
"Composer\\Config::disableProcessTimeout",
"vendor/bin/paratest --runner WrapperRunner"
],
"coverage": "vendor/bin/phpunit --coverage-html build/reports/html --coverage-clover build/reports/clover.xml",
"fmt": "vendor/bin/mago fmt",
"lint:fix": "vendor/bin/mago lint --fix --format-after-fix",
"style": "composer fmt && composer lint:fix",
"test": "composer phpunit",
"test:stop": "composer phpunit -- --stop-on-error --stop-on-failure",
"test:parallel": "composer paratest",
"lint": "vendor/bin/mago lint --potentially-unsafe --minimum-fail-level=note",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=1G",
"rector": "vendor/bin/rector process --no-ansi",
Expand Down
20 changes: 16 additions & 4 deletions packages/intl/src/Catalog/XliffParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tempest\Intl\Catalog;

use DOMDocument;
use DOMDocumentType;
use DOMElement;
use DOMNodeList;
use DOMText;
Expand All @@ -13,6 +14,7 @@
final readonly class XliffParser
{
private const string VERSION_1_NAMESPACE = 'urn:oasis:names:tc:xliff:document:1.2';

private const string PGS_NAMESPACE = 'urn:oasis:names:tc:xliff:pgs:1.0';

private const string VERSION_2_NAMESPACE = 'urn:oasis:names:tc:xliff:document:2.0';
Expand Down Expand Up @@ -48,7 +50,7 @@ private static function loadDocument(string $contents): DOMDocument
throw new RuntimeException('Invalid XLIFF document: malformed XML.');
}

if ($document->doctype !== null) {
if ($document->doctype instanceof DOMDocumentType) {
throw new RuntimeException('Invalid XLIFF document: document types are not allowed.');
}
} finally {
Expand Down Expand Up @@ -159,8 +161,11 @@ private static function parseVersion2(DOMDocument $document, DOMElement $root):

for ($index = 0; $index < $unit->childNodes->length; $index++) {
$part = $unit->childNodes->item($index);
if (! $part instanceof DOMElement) {
continue;
}

if (! $part instanceof DOMElement || ! in_array($part->localName, ['segment', 'ignorable'], true)) {
if (! in_array($part->localName, ['segment', 'ignorable'], true)) {
continue;
}

Expand Down Expand Up @@ -238,7 +243,11 @@ private static function parsePgsUnit(DOMXPath $xpath, DOMElement $unit, string $
));

foreach ($segments as $segment) {
if (! $segment instanceof DOMElement || ! $segment->hasAttributeNS(self::PGS_NAMESPACE, 'case')) {
if (! $segment instanceof DOMElement) {
continue;
}

if (! $segment->hasAttributeNS(self::PGS_NAMESPACE, 'case')) {
continue;
}

Expand Down Expand Up @@ -426,8 +435,11 @@ private static function findReferencedData(DOMElement $element, DOMElement $unit

for ($index = 0; $index < $unit->childNodes->length; $index++) {
$originalData = $unit->childNodes->item($index);
if (! $originalData instanceof DOMElement) {
continue;
}

if (! $originalData instanceof DOMElement || $originalData->localName !== 'originalData') {
if ($originalData->localName !== 'originalData') {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/intl/tests/XliffParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class XliffParserTest extends TestCase
#[Test]
public function parses_xliff_1_2_resource_identifiers_and_source_aliases(): void
{
$messages = XliffParser::parse(<<<'XLIFF'
$messages = XliffParser::parse(<<<'XLIFF_WRAP'
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="namespace1" datatype="plaintext" source-language="en-US" target-language="de-CH">
<body>
Expand All @@ -40,7 +40,7 @@ public function parses_xliff_1_2_resource_identifiers_and_source_aliases(): void
</body>
</file>
</xliff>
XLIFF);
XLIFF_WRAP);

$this->assertSame('Hallo', $messages['key1']);
$this->assertSame('Hallo', $messages['Hello']);
Expand Down
10 changes: 5 additions & 5 deletions packages/process/tests/GenericProcessExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function run_pending_process(): void
public function start(): void
{
$executor = new GenericProcessExecutor();
$process = $executor->start('echo hello');
$process = $executor->start('"' . PHP_BINARY . '" -r "usleep(500000); echo \'hello\';"');

$this->assertIsInt($process->pid);
$this->assertTrue($process->running);
Expand All @@ -54,10 +54,10 @@ public function start(): void

$this->assertNull($process->pid);
$this->assertFalse($process->running);
$this->assertStringEqualsStringIgnoringLineEndings("hello\n", $process->output);
$this->assertSame('hello', $process->output);
$this->assertSame('', $process->errorOutput);

$this->assertStringEqualsStringIgnoringLineEndings("hello\n", $result->output);
$this->assertSame('hello', $result->output);
$this->assertSame('', $result->errorOutput);
$this->assertSame(0, $result->exitCode);
}
Expand All @@ -66,7 +66,7 @@ public function start(): void
public function wait_callback(): void
{
$executor = new GenericProcessExecutor();
$process = $executor->start('echo hello');
$process = $executor->start('"' . PHP_BINARY . '" -r "usleep(500000); echo \'hello\';"');

$output = [];
$process->wait(function (OutputChannel $channel, string $data) use (&$output) {
Expand All @@ -76,7 +76,7 @@ public function wait_callback(): void

$this->assertCount(1, $output);
$this->assertArrayHasKey(OutputChannel::OUTPUT->value, $output);
$this->assertStringEqualsStringIgnoringLineEndings("hello\n", $output[OutputChannel::OUTPUT->value][0]);
$this->assertSame('hello', $output[OutputChannel::OUTPUT->value][0]);
}

#[Test]
Expand Down
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest20/Tempest20RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest20;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest20RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest20/tempest20_rector.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([
TempestSetList::TEMPEST_20,
]);
])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest28/Tempest28RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest28;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest28RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest28/tempest28_rector.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([
TempestSetList::TEMPEST_28,
]);
])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest3/Tempest3RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest3;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest3RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest3/tempest30_rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([TempestSetList::TEMPEST_30]);
->withSets([TempestSetList::TEMPEST_30])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest310/Tempest310RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest310;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest310RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest310/tempest310_rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([TempestSetList::TEMPEST_310]);
->withSets([TempestSetList::TEMPEST_310])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest314/Tempest314RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest314;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest314RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest314/tempest314_rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([TempestSetList::TEMPEST_314]);
->withSets([TempestSetList::TEMPEST_314])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 0 additions & 2 deletions packages/upgrade/tests/Tempest34/Tempest34RectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Tempest\Upgrade\Tests\Tempest34;

use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Tempest\Upgrade\Tests\RectorTester;

#[RunTestsInSeparateProcesses]
final class Tempest34RectorTest extends TestCase
{
private RectorTester $rector {
Expand Down
4 changes: 3 additions & 1 deletion packages/upgrade/tests/Tempest34/tempest34_rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
use Rector\Config\RectorConfig;
use Tempest\Upgrade\Set\TempestSetList;

return RectorConfig::configure()
->withSets([TempestSetList::TEMPEST_34]);
->withSets([TempestSetList::TEMPEST_34])
->withCache(cacheClass: MemoryCacheStorage::class);
2 changes: 1 addition & 1 deletion packages/view/tests/StandaloneViewRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function invalid_view_component_paths_within_config(): void
#[Test]
public function with_cache_enabled(): void
{
$viewCache = ViewCache::create();
$viewCache = ViewCache::create(path: sys_get_temp_dir() . '/tempest-view-cache-tests-' . getmypid());
$viewCache->clear();

$renderer =
Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
</exclude>
</source>
<php>
<ini name="memory_limit" value="2G" />
<env name="ENVIRONMENT" value="testing" />
<env name="BASE_URI" value="" />
<env name="INTERNAL_CACHES" value="null" />
<env name="CONFIG_CACHE" value="true" />
<env name="DISCOVERY_CACHE" value="true" />
</php>
</phpunit>
6 changes: 5 additions & 1 deletion tests/Fixtures/Config/database.mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

use Tempest\Database\Config\MysqlConfig;

return new MysqlConfig();
use function Tempest\env;

return new MysqlConfig(
database: 'app' . env('TEST_TOKEN', ''),
);
2 changes: 1 addition & 1 deletion tests/Fixtures/Config/database.postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
return new PostgresConfig(
username: env('POSTGRES_USER', 'postgres'),
password: env('POSTGRES_PASSWORD', '') ?? '',
database: env('POSTGRES_DB', 'app'),
database: env('POSTGRES_DB', 'app') . env('TEST_TOKEN', ''),
);
7 changes: 6 additions & 1 deletion tests/Fixtures/Config/database.sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
declare(strict_types=1);

use Tempest\Database\Config\SQLiteConfig;
use Tempest\Support\Filesystem;

use function Tempest\env;

$directory = dirname(__DIR__, 3) . '/.tempest/test-databases';

Filesystem\ensure_directory_exists($directory);

return new SQLiteConfig(
path: __DIR__ . '/../database' . env('TEST_TOKEN', 'default') . '.sqlite',
path: $directory . '/database' . env('TEST_TOKEN', 'default') . '.sqlite',
);
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
__DIR__ . '/install-authentication',
new Psr4Namespace('App\\', __DIR__ . '/install-authentication/App'),
)
->setRoot(__DIR__ . '/install')
->setRoot(__DIR__ . '/install-authentication')
->put('.env.example', '')
->put('.env', '');
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Auth/Installer/OAuthInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
__DIR__ . '/install-oauth',
new Psr4Namespace('App\\', __DIR__ . '/install-oauth/App'),
)
->setRoot(__DIR__ . '/install')
->setRoot(__DIR__ . '/install-oauth')
->put('.env.example', '')
->put('.env', '');
}
Expand Down
Loading
Loading