Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tools #23

Merged
merged 2 commits into from
Dec 3, 2023
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
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ parameters:
count: 1
path: tests/App/AppKernel.php

-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:createStub\\(\\)\\.$#"
count: 6
path: tests/Block/Breadcrumb/BreadcrumbTest.php

-
message: "#^Parameter \\#1 \\$services of class Nucleos\\\\SeoBundle\\\\Sitemap\\\\SitemapServiceManager constructor expects array\\<Nucleos\\\\SeoBundle\\\\Sitemap\\\\SitemapServiceInterface\\>, array\\<string, stdClass\\> given\\.$#"
count: 1
Expand Down
5 changes: 4 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.7.7@e028ba46ba0d7f9a78bc3201c251e137383e145f">
<files psalm-version="5.16.0@2897ba636551a8cb61601cc26f6ccfbba6c36591">
<file src="src/DependencyInjection/Configuration.php">
<UndefinedMethod>
<code>children</code>
Expand Down Expand Up @@ -61,5 +61,8 @@
<code>$data</code>
<code>$data</code>
</InvalidArgument>
<UnsupportedPropertyReferenceUsage>
<code><![CDATA[$data = &$this->urls[$index]]]></code>
</UnsupportedPropertyReferenceUsage>
</file>
</files>
4 changes: 1 addition & 3 deletions src/Exception/SitemapNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

final class SitemapNotFoundException extends NotFoundHttpException
{
}
final class SitemapNotFoundException extends NotFoundHttpException {}
4 changes: 2 additions & 2 deletions src/Test/AbstractSitemapServiceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final protected function process(SitemapDefinitionInterface $sitemap): void
$result = $this->service->execute($sitemap);

$count = \count($this->urls);
static::assertCount($count, $result);
self::assertCount($count, $result);

if (0 === $count) {
return;
Expand Down Expand Up @@ -91,7 +91,7 @@ final protected function assertSitemap(string $location, int $priority, string $

final protected function assertSitemapCount(int $count): void
{
static::assertCount($count, $this->urls);
self::assertCount($count, $this->urls);
}

private function getUrlIndex(UrlInterface $url): int
Expand Down
4 changes: 2 additions & 2 deletions tests/Action/SitemapXMLActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testExecute(): void

$response = $action();

static::assertSame('text/xml', $response->headers->get('Content-Type'));
static::assertSame('<xml></xml>', $response->getContent());
self::assertSame('text/xml', $response->headers->get('Content-Type'));
self::assertSame('<xml></xml>', $response->getContent());
}
}
10 changes: 5 additions & 5 deletions tests/Action/SitemapXMLActionWebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ final class SitemapXMLActionWebTest extends WebTestCase
{
public function testSitemapXml(): void
{
$client = static::createClient();
$client = self::createClient();

$client->request('GET', '/sitemap.xml');

$response = $client->getResponse();

static::assertSame(200, $client->getResponse()->getStatusCode());
static::assertResponseIsSuccessful();
static::assertSame('text/xml; charset=UTF-8', $response->headers->get('Content-Type'));
static::assertSame('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"><url><loc>example.com</loc></url><url><loc>/foo</loc><priority>50</priority></url><url><loc>/bar</loc><priority>75</priority></url></urlset>', $response->getContent());
self::assertSame(200, $client->getResponse()->getStatusCode());
self::assertResponseIsSuccessful();
self::assertSame('text/xml; charset=UTF-8', $response->headers->get('Content-Type'));
self::assertSame('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"><url><loc>example.com</loc></url><url><loc>/foo</loc><priority>50</priority></url><url><loc>/bar</loc><priority>75</priority></url></urlset>', $response->getContent());
}
}
4 changes: 1 addition & 3 deletions tests/App/Sitemap/DemoSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

final class DemoSitemap implements SitemapServiceInterface
{
public function configureSettings(OptionsResolver $resolver): void
{
}
public function configureSettings(OptionsResolver $resolver): void {}

public function execute(SitemapDefinitionInterface $sitemap): array
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Block/Breadcrumb/BreadcrumbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testBlockService(): void
$this->createStub(FactoryInterface::class)
);

static::assertTrue($blockService->handleContext('test'));
self::assertTrue($blockService->handleContext('test'));
}

public function testBlockExectute(): void
Expand All @@ -53,7 +53,7 @@ public function testBlockExectute(): void
);

$menu = $this->createStub(ItemInterface::class);
$menuFactory->expects(static::once())->method('createItem')->with('breadcrumb')
$menuFactory->expects(self::once())->method('createItem')->with('breadcrumb')
->willReturn($menu)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ private function process(): void
*/
private function assertServiceOrder(array $services): void
{
static::assertSame($services, $this->getCalledServices());
self::assertSame($services, $this->getCalledServices());
}
}
12 changes: 6 additions & 6 deletions tests/DependencyInjection/Compiler/ServiceCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public function testServicesExistsAndCanBeOverridden(): void

(new ServiceCompilerPass())->process($container);

static::assertTrue($container->has('nucleos_seo.page'));
static::assertTrue($container->has(SeoPageInterface::class));
static::assertSame($container->get('nucleos_seo.page'), $container->get(SeoPageInterface::class));
self::assertTrue($container->has('nucleos_seo.page'));
self::assertTrue($container->has(SeoPageInterface::class));
self::assertSame($container->get('nucleos_seo.page'), $container->get(SeoPageInterface::class));

static::assertInstanceOf(SeoPage::class, $container->get(SeoPageInterface::class));
self::assertInstanceOf(SeoPage::class, $container->get(SeoPageInterface::class));
}

public function testGlobalTitle(): void
Expand All @@ -69,7 +69,7 @@ public function testGlobalTitle(): void

\assert($page instanceof SeoPageInterface);

static::assertSame('Project name', $page->getOriginalTitle());
static::assertSame('Prefix Project name Suffix', $page->getTitle());
self::assertSame('Project name', $page->getOriginalTitle());
self::assertSame('Prefix Project name Suffix', $page->getTitle());
}
}
20 changes: 10 additions & 10 deletions tests/DependencyInjection/Compiler/SitemapCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ protected function setUp(): void

public function testProcess(): void
{
$this->serviceManager->expects(static::once())->method('addMethodCall')
->with('addSitemap', static::callback(static function (array $args): bool {
$this->serviceManager->expects(self::once())->method('addMethodCall')
->with('addSitemap', self::callback(static function (array $args): bool {
return 'acme.sitemap' === $args[0] && $args[1] instanceof Reference;
}))
;

$this->definitionManager->expects(static::once())->method('addMethodCall')->with('addDefinition', [
$this->definitionManager->expects(self::once())->method('addMethodCall')->with('addDefinition', [
'acme.sitemap',
]);

Expand All @@ -72,9 +72,9 @@ public function testProcess(): void
$compiler = new SitemapCompilerPass();
$compiler->process($this->container);

static::assertTrue($sitemapDefinition->isPublic());
self::assertTrue($sitemapDefinition->isPublic());

$this->definitionManager->expects(static::never())->method('addMethodCall');
$this->definitionManager->expects(self::never())->method('addMethodCall');
}

public function testProcessWithNoServices(): void
Expand All @@ -84,14 +84,14 @@ public function testProcessWithNoServices(): void
$compiler = new SitemapCompilerPass();
$compiler->process($this->container);

static::assertSame([], $this->container->getParameter('nucleos_seo.sitemap.static_urls'));
self::assertSame([], $this->container->getParameter('nucleos_seo.sitemap.static_urls'));

$this->definitionManager->expects(static::never())->method('addMethodCall');
$this->definitionManager->expects(self::never())->method('addMethodCall');
}

public function testProcessWithStaticUrls(): void
{
$this->definitionManager->expects(static::once())->method('addMethodCall')->with('addDefinition', [
$this->definitionManager->expects(self::once())->method('addMethodCall')->with('addDefinition', [
StaticSitemapService::class,
[
[
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testProcessWithEmptyGroups(): void
$compiler = new SitemapCompilerPass();
$compiler->process($this->container);

$this->serviceManager->expects(static::never())->method('addMethodCall');
$this->definitionManager->expects(static::never())->method('addMethodCall');
$this->serviceManager->expects(self::never())->method('addMethodCall');
$this->definitionManager->expects(self::never())->method('addMethodCall');
}
}
8 changes: 4 additions & 4 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testDefaultConfiguration(): void
],
];

static::assertSame($expected, $this->processConfiguration([[]]));
self::assertSame($expected, $this->processConfiguration([[]]));
}

public function testKeysAreNotNormalized(): void
Expand All @@ -62,7 +62,7 @@ public function testKeysAreNotNormalized(): void
$values
);

static::assertSame($expected, $config);
self::assertSame($expected, $config);
}

public function testWithYamlConfig(): void
Expand All @@ -80,9 +80,9 @@ public function testWithYamlConfig(): void
$values
);

static::assertSame($expected, $config);
self::assertSame($expected, $config);

static::assertSame('website', $config['page']['metas']['property']['og:type']);
self::assertSame('website', $config['page']['metas']['property']['og:type']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/DependencyInjection/NucleosSeoExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function testBlocksLoading(): void
$extension = new NucleosSeoExtension();
$extension->load([[]], $container);

static::assertTrue($container->hasDefinition('nucleos_seo.block.breadcrumb.homepage'));
self::assertTrue($container->hasDefinition('nucleos_seo.block.breadcrumb.homepage'));

$container = new ContainerBuilder();
$container->setParameter('kernel.bundles', []);

$extension->load([[]], $container);

static::assertFalse($container->hasDefinition('nucleos_seo.block.breadcrumb.homepage'));
self::assertFalse($container->hasDefinition('nucleos_seo.block.breadcrumb.homepage'));
}

public function testLoadWithCacheService(): void
Expand Down
4 changes: 1 addition & 3 deletions tests/Fixtures/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@
use Exception;
use Psr\SimpleCache\InvalidArgumentException as PsrException;

final class InvalidArgumentException extends Exception implements PsrException
{
}
final class InvalidArgumentException extends Exception implements PsrException {}
4 changes: 1 addition & 3 deletions tests/Fixtures/SitemapDefinitionStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public function getTtl(): int
return 42;
}

public function setSettings(array $settings = []): void
{
}
public function setSettings(array $settings = []): void {}

public function getSettings(): array
{
Expand Down
20 changes: 10 additions & 10 deletions tests/Generator/SitemapGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testToXMLWithInvalidDefinition(): void
$this->defintionManager
);

static::assertSame($expected, $generator->toXML());
self::assertSame($expected, $generator->toXML());
}

public function testToXMLWithNoEntries(): void
Expand All @@ -93,7 +93,7 @@ public function testToXMLWithNoEntries(): void
$this->defintionManager
);

static::assertSame($expected, $generator->toXML());
self::assertSame($expected, $generator->toXML());
}

public function testToXML(): void
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testToXML(): void
$this->defintionManager
);

static::assertSame($expected, $generator->toXML());
self::assertSame($expected, $generator->toXML());
}

public function testToXMLWithExistingCache(): void
Expand Down Expand Up @@ -186,10 +186,10 @@ public function testToXMLWithExistingCache(): void
;

$cache = $this->createMock(CacheInterface::class);
$cache->method('has')->with(static::stringStartsWith('Sitemap_'))
$cache->method('has')->with(self::stringStartsWith('Sitemap_'))
->willReturn(true)
;
$cache->method('get')->with(static::stringStartsWith('Sitemap_'))
$cache->method('get')->with(self::stringStartsWith('Sitemap_'))
->willReturn($xmlEntry)
;

Expand All @@ -199,7 +199,7 @@ public function testToXMLWithExistingCache(): void
$cache
);

static::assertSame($expected, $generator->toXML());
self::assertSame($expected, $generator->toXML());
}

/**
Expand Down Expand Up @@ -250,18 +250,18 @@ public function testToXMLWithExpiredCache(): void
;

$cache = $this->createMock(CacheInterface::class);
$cache->method('has')->with(static::stringStartsWith('Sitemap_'))
$cache->method('has')->with(self::stringStartsWith('Sitemap_'))
->willReturn(false)
;
$cache->method('set')->with(static::stringStartsWith('Sitemap_'), $xmlEntry, 42);
$cache->method('set')->with(self::stringStartsWith('Sitemap_'), $xmlEntry, 42);

$generator = new SitemapGenerator(
$this->sitemapServiceManager,
$this->defintionManager,
$cache
);

static::assertSame($expected, $generator->toXML());
self::assertSame($expected, $generator->toXML());
}

public function testToXMLWithCacheException(): void
Expand All @@ -282,7 +282,7 @@ public function testToXMLWithCacheException(): void
;

$cache = $this->createMock(CacheInterface::class);
$cache->method('has')->with(static::stringStartsWith('Sitemap_'))
$cache->method('has')->with(self::stringStartsWith('Sitemap_'))
->willThrowException(new InvalidArgumentException())
;

Expand Down
4 changes: 2 additions & 2 deletions tests/NucleosSeoBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function testGetContainerExtension(): void
{
$bundle = new NucleosSeoBundle();

static::assertInstanceOf(NucleosSeoExtension::class, $bundle->getContainerExtension());
self::assertInstanceOf(NucleosSeoExtension::class, $bundle->getContainerExtension());
}

public function testBuild(): void
{
$containerBuilder = $this->createMock(ContainerBuilder::class);
$containerBuilder->expects(static::exactly(3))->method('addCompilerPass');
$containerBuilder->expects(self::exactly(3))->method('addCompilerPass');

$bundle = new NucleosSeoBundle();
$bundle->build($containerBuilder);
Expand Down
Loading
Loading