Skip to content

Commit

Permalink
Re-allow DI>4.4.0 & upgrade di test package
Browse files Browse the repository at this point in the history
  • Loading branch information
mazsudo authored and greg0ire committed Jan 27, 2020
1 parent 8df31aa commit cd23a18
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ env:
- SYMFONY_DEPRECATIONS_HELPER=max[self]=0
- TARGET=test
- UPSTREAM_URL=https://github.com/sonata-project/SonataPageBundle.git
- PHPUNIT_VERSION=7
- PHPUNIT_VERSION=8

matrix:
fast_finish: true
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"symfony/config": "^3.4 || ^4.2",
"symfony/console": "^3.4 || ^4.2",
"symfony/debug": "^3.4 || ^4.2",
"symfony/dependency-injection": "^3.4 || ^4.2,<4.4.0",
"symfony/dependency-injection": "^3.4 || ^4.2",
"symfony/form": "^3.4 || ^4.2",
"symfony/http-foundation": "^3.4.31 || ^4.2",
"symfony/http-kernel": "^3.4 || ^4.2",
Expand All @@ -60,7 +60,7 @@
"require-dev": {
"friendsofsymfony/rest-bundle": "^2.1",
"jms/serializer-bundle": "^1.0 || ^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"nelmio/api-doc-bundle": "^2.4",
"symfony/phpunit-bridge": "^4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Block/PageListBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PageListBlockServiceTest extends AbstractBlockServiceTestCase
*/
protected $pageManager;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/CmsManager/CmsPageManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CmsPageManagerTest extends TestCase
/**
* Setup manager object to test.
*/
public function setUp()
protected function setUp(): void
{
$this->blockInteractor = $this->getMockBlockInteractor();
$this->pageManager = $this->createMock(PageManagerInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/CmsManager/CmsSnapshotManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CmsSnapshotManagerTest extends TestCase
/**
* Setup manager object to test.
*/
public function setUp()
protected function setUp(): void
{
$this->blockInteractor = $this->getMockBlockInteractor();
$this->snapshotManager = $this->createMock(SnapshotManagerInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BaseCommandTest extends TestCase
/**
* Sets up a new BaseCommand instance.
*/
public function setUp()
protected function setUp(): void
{
$this->command = $this->getMockBuilder(BaseCommand::class)
->disableOriginalConstructor()
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CloneSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CloneSiteCommandTest extends TestCase
*/
private $blockManager;

protected function setUp()
protected function setUp(): void
{
$this->siteManager = $this->prophesize(SiteManagerInterface::class);
$this->pageManager = $this->prophesize(PageManagerInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateBlockContainerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CreateBlockContainerCommandTest extends TestCase
*/
protected $container;

public function setUp()
protected function setUp(): void
{
$this->blockInteractor = $this->prophesize(BlockInteractor::class);

Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateSiteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CreateSiteCommandTest extends TestCase
*/
private $siteManager;

protected function setUp()
protected function setUp(): void
{
$this->siteManager = $this->prophesize(SiteManagerInterface::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function providerRoutedAutoRegister()
];
}

protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new CmfRouterCompilerPass());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DependencyInjection/SonataPageExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public function testDatePickerFormTheme()
));
}

protected function getContainerExtensions()
protected function getContainerExtensions(): array
{
return [new SonataPageExtension()];
}

protected function getMinimalConfiguration()
protected function getMinimalConfiguration(): array
{
return [
'multisite' => 'host',
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/PageSelectorTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PageSelectorTypeTest extends TestCase

protected $site;

public function setUp()
protected function setUp(): void
{
$pages = [];

Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/TemplateChoiceTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TemplateChoiceTypeTest extends TestCase
/**
* setup each unit test.
*/
public function setUp()
protected function setUp(): void
{
$this->manager = $this->createMock(TemplateManagerInterface::class);
$this->type = new TemplateChoiceType($this->manager);
Expand Down
2 changes: 1 addition & 1 deletion tests/Listener/ExceptionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ExceptionListenerTest extends TestCase
/**
* setup unit test.
*/
public function setUp()
protected function setUp(): void
{
// mock dependencies
$this->siteSelector = $this->createMock(SiteSelectorInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Listener/ResponseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ResponseListenerTest extends TestCase
/**
* setup unit test.
*/
public function setUp()
protected function setUp(): void
{
$this->decoratorStrategy = $this->createMock(DecoratorStrategyInterface::class);
$this->pageServiceManager = $this->createMock(PageServiceManagerInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Page/PageServiceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PageServiceManagerTest extends TestCase
*/
protected $manager;

public function setUp()
protected function setUp(): void
{
$this->router = $this->createMock(RouterInterface::class);
$this->manager = new PageServiceManager($this->router);
Expand Down
2 changes: 1 addition & 1 deletion tests/Page/Service/DefaultPageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DefaultPageServiceTest extends TestCase
*/
protected $seoPage;

public function setUp()
protected function setUp(): void
{
$name = 'my name';
$this->templateManager = $this->createMock(TemplateManagerInterface::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/Request/RequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

class RequestFactoryTest extends TestCase
{
public function setup()
protected function setUp(): void
{
Request::setFactory(null);
}

public function tearDown()
protected function tearDown(): void
{
Request::setFactory(null);
}
Expand Down
64 changes: 62 additions & 2 deletions tests/Resources/XliffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,75 @@

namespace Sonata\PageBundle\Tests\Resources;

use Sonata\CoreBundle\Test\XliffValidatorTestCase;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Loader\XliffFileLoader;

class XliffTest extends XliffValidatorTestCase
class XliffTest extends TestCase
{
/**
* @var XliffFileLoader
*/
protected $loader;

/**
* @var string[]
*/
protected $errors = [];

protected function setUp(): void
{
$this->loader = new XliffFileLoader();
}

/**
* @dataProvider getXliffPaths
*/
public function testXliff($path)
{
$this->validatePath($path);

if (\count($this->errors) > 0) {
$this->fail(sprintf('Unable to parse xliff files: %s', implode(', ', $this->errors)));
}

$this->assertCount(
0,
$this->errors,
sprintf('Unable to parse xliff files: %s', implode(', ', $this->errors))
);
}

/**
* @return array List all path to validate xliff
*/
public function getXliffPaths()
{
return [[__DIR__.'/../../Resources/translations']];
}

/**
* @param string $file The path to the xliff file
*/
protected function validateXliff($file)
{
try {
$this->loader->load($file, 'en');
$this->assertTrue(true, sprintf('Successful loading file: %s', $file));
} catch (InvalidResourceException $e) {
$this->errors[] = sprintf('%s => %s', $file, $e->getMessage());
}
}

/**
* @param string $path The path to lookup for Xliff file
*/
protected function validatePath($path)
{
$files = glob(sprintf('%s/*.xliff', $path));

foreach ($files as $file) {
$this->validateXliff($file);
}
}
}
2 changes: 1 addition & 1 deletion tests/Route/CmsPageRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CmsPageRouterTest extends TestCase
/**
* Setup test object with its dependencies.
*/
public function setup()
protected function setUp(): void
{
$this->cmsSelector = $this->createMock(CmsManagerSelectorInterface::class);
$this->siteSelector = $this->createMock(SiteSelectorInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Route/RoutePageGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RoutePageGeneratorTest extends TestCase
/**
* Set up dependencies.
*/
public function setUp()
protected function setUp(): void
{
$this->routePageGenerator = $this->getRoutePageGenerator();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Site/BaseLocaleSiteSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ abstract class BaseLocaleSiteSelectorTest extends TestCase
*/
protected $siteSelector;

protected function setUp()
protected function setUp(): void
{
throw new \RuntimeException('You must define a setUp method to initialize the site selector.');
}

/**
* Cleanups the site selector.
*/
protected function tearDown()
protected function tearDown(): void
{
unset($this->siteSelector);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Site/HostByLocaleSiteSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
class HostByLocaleSiteSelectorTest extends BaseLocaleSiteSelectorTest
{
protected function setUp()
protected function setUp(): void
{
$siteManager = $this->createMock(SiteManagerInterface::class);
$decoratorStrategy = $this->createMock(DecoratorStrategyInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Site/HostPathByLocaleSiteSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class HostPathByLocaleSiteSelectorTest extends BaseLocaleSiteSelectorTest
{
protected function setUp()
protected function setUp(): void
{
$siteManager = $this->createMock(SiteManagerInterface::class);
$decoratorStrategy = $this->createMock(DecoratorStrategyInterface::class);
Expand Down

0 comments on commit cd23a18

Please sign in to comment.