PHPUnit 10.3

This commit is contained in:
Alexander M. Turek
2023-08-23 23:17:05 +02:00
parent a4bce292cf
commit 24e52af85f
9 changed files with 279 additions and 326 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,5 @@
/.phpcs-cache
/.phpunit.result.cache
/.phpunit.cache
/.webpack-build
/build-*
/config/local.yml

View File

@@ -44,7 +44,7 @@
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.2",
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.3",
"symfony/css-selector": "^6.3",
"symfony/dom-crawler": "^6.3",
"symfony/error-handler": "^6.3",

562
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,18 +3,19 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
>
<coverage/>
<testsuites>
<testsuite name="Doctrine Website Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<source>
<include>
<directory>./lib</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>

View File

@@ -53,7 +53,7 @@ class CacheClearerTest extends TestCase
$this->rootDir,
$this->env,
])
->setMethods(['glob'])
->onlyMethods(['glob'])
->getMock();
}
}

View File

@@ -8,6 +8,7 @@ use Doctrine\Website\Docs\CodeBlockConsoleRenderer;
use Doctrine\Website\Docs\CodeBlockRenderer;
use Doctrine\Website\Docs\CodeBlockWithLineNumbersRenderer;
use Doctrine\Website\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
class CodeBlockRendererTest extends TestCase
@@ -36,7 +37,7 @@ class CodeBlockRendererTest extends TestCase
self::assertSame('expected', $this->codeBlockRenderer->render($lines, $language));
}
/** @dataProvider getConsoleLanguages */
#[DataProvider('getConsoleLanguages')]
public function testRenderConsole(string $consoleLanguage): void
{
$lines = [
@@ -54,7 +55,7 @@ class CodeBlockRendererTest extends TestCase
}
/** @return string[][] */
public function getConsoleLanguages(): array
public static function getConsoleLanguages(): array
{
return [
['console'],

View File

@@ -173,7 +173,7 @@ class FunctionalTest extends TestCase
self::assertCount(3, $crawler->filter('nav.breadcrumbs ol.breadcrumb li.breadcrumb-item'));
}
self::assertFileNotExists($this->getFullPath(sprintf(
self::assertFileDoesNotExist($this->getFullPath(sprintf(
'/projects/%s/en/current/meta.php',
$project->getDocsSlug(),
)));

View File

@@ -27,7 +27,7 @@ class ProjectExtensionTest extends TestCase
$this->projectRepository,
'',
])
->setMethods(['fileExists'])
->onlyMethods(['fileExists'])
->getMock();
}

View File

@@ -57,7 +57,7 @@ class WebsiteBuilderTest extends TestCase
$this->cacheDir,
$this->webpackBuildDir,
])
->setMethods(['filePutContents'])
->onlyMethods(['filePutContents'])
->getMock();
}
@@ -82,13 +82,16 @@ class WebsiteBuilderTest extends TestCase
->method('run')
->with('cd /data/doctrine-website-build-staging && npm run build');
$this->filesystem->expects(self::exactly(2))
->method('mirror')
->withConsecutive(
[$this->webpackBuildDir, $buildDir . '/frontend'],
[$this->cacheDir . '/data', $buildDir . '/website-data'],
);
$mirrored = [];
$this->filesystem->method('mirror')
->willReturnCallback(static function (string $originDir, string $targetDir) use (&$mirrored): void {
$mirrored[$originDir] = $targetDir;
});
$this->websiteBuilder->build($output, $buildDir, $env);
self::assertSame($buildDir . '/frontend', $mirrored[$this->webpackBuildDir]);
self::assertSame($buildDir . '/website-data', $mirrored[$this->cacheDir . '/data']);
}
}