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

Test sf4 #4742

Merged
merged 8 commits into from
Nov 7, 2017
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
2 changes: 1 addition & 1 deletion Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public function getParent();
/**
* @param AdminInterface $admin
*/
public function setParent(AdminInterface $admin);
public function setParent(self $admin);

/**
* Returns true if the Admin class has an Parent Admin defined.
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/core.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sonata.admin.pool" class="Sonata\AdminBundle\Admin\Pool">
<service id="sonata.admin.pool" class="Sonata\AdminBundle\Admin\Pool" public="true">
<argument type="service" id="service_container"/>
<argument/>
<argument/>
Expand Down
2 changes: 1 addition & 1 deletion Route/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getCode($name)
*
* @return RouteCollection
*/
public function addCollection(RouteCollection $collection)
public function addCollection(self $collection)
{
foreach ($collection->getElements() as $code => $route) {
$this->elements[$code] = $route;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
use PHPUnit\Framework\TestCase;
use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
use Sonata\AdminBundle\DependencyInjection\SonataAdminExtension;
use Sonata\DoctrinePHPCRAdminBundle\Route\PathInfoBuilderSlashes;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

/**
Expand Down Expand Up @@ -194,11 +197,20 @@ function ($element) {
return 'setRouteBuilder' == $element[0];
}
));
$this->assertSame(
'sonata.admin.route.path_info_slashes',
(string) $articleRouteBuilderMethodCall[1][0],
'The article admin uses the odm, and should therefore use the path_info_slashes router.'
);
$definitionOrReference = $articleRouteBuilderMethodCall[1][0];
if ($definitionOrReference instanceof Definition) {
$this->assertSame(
PathInfoBuilderSlashes::class,
$articleRouteBuilderMethodCall[1][0]->getClass(),
'The article admin uses the odm, and should therefore use the path_info_slashes router.'
);
} else {
$this->assertSame(
'sonata.admin.route.path_info_slashes',
(string) $articleRouteBuilderMethodCall[1][0],
'The article admin uses the odm, and should therefore use the path_info_slashes router.'
);
}
}

public function testProcessSortAdmins()
Expand Down Expand Up @@ -479,14 +491,22 @@ public function testProcessAbstractAdminServiceInServiceDefinition()
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Post', ''])
->setAbstract(true);

$adminDefinition = new DefinitionDecorator('sonata_abstract_post_admin');
// NEXT_MAJOR: Simplify this when dropping sf < 3.3
$adminDefinition = class_exists(ChildDefinition::class) ?
new ChildDefinition('sonata_abstract_post_admin') :
new DefinitionDecorator('sonata_abstract_post_admin');
$adminDefinition
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAbstractServiceAdmin')
->setArguments([0 => 'extra_argument_1'])
->addTag('sonata.admin', ['group' => 'sonata_post_one_group', 'manager_type' => 'orm']);

$adminTwoDefinition = new DefinitionDecorator('sonata_abstract_post_admin');
// NEXT_MAJOR: Simplify this when dropping sf < 3.3
$adminTwoDefinition = class_exists(ChildDefinition::class) ?
new ChildDefinition('sonata_abstract_post_admin') :
new DefinitionDecorator('sonata_abstract_post_admin');
$adminTwoDefinition
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAbstractServiceAdmin')
->setArguments([0 => 'extra_argument_2', 'index_0' => 'should_not_override'])
->addTag('sonata.admin', ['group' => 'sonata_post_two_group', 'manager_type' => 'orm']);
Expand Down Expand Up @@ -678,21 +698,25 @@ private function getContainer()
// Add admin definition's
$container
->register('sonata_news_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\News', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin', ['group' => 'sonata_group_two', 'label' => '5 Entry', 'manager_type' => 'orm']);
$container
->register('sonata_post_admin')
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setPublic(true)
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Post', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin', ['group' => 'sonata_group_one', 'manager_type' => 'orm']);
$container
->register('sonata_article_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Article', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin', ['group' => 'sonata_group_one', 'label' => '1 Entry', 'manager_type' => 'doctrine_phpcr']);
$container
->register('sonata_report_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Report', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin', ['group' => 'sonata_report_group', 'manager_type' => 'orm', 'on_top' => true]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,19 @@ private function getContainer()
// Add admin definition's
$container
->register('sonata_post_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Post', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin');
$container
->register('sonata_news_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\News', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin');
$container
->register('sonata_article_admin')
->setPublic(true)
->setClass('Sonata\AdminBundle\Tests\DependencyInjection\MockAdmin')
->setArguments(['', 'Sonata\AdminBundle\Tests\DependencyInjection\Article', 'SonataAdminBundle:CRUD'])
->addTag('sonata.admin');
Expand All @@ -389,22 +392,28 @@ private function getContainer()

$container
->register('sonata_extension_publish')
->setPublic(true)
->setClass($extensionClass);
$container
->register('sonata_extension_history')
->setPublic(true)
->setClass($extensionClass);
$container
->register('sonata_extension_order')
->setPublic(true)
->setClass($extensionClass);
$container
->register('sonata_extension_timestamp')
->setPublic(true)
->setClass($extensionClass);
$container
->register('sonata_extension_security')
->setPublic(true)
->setClass($extensionClass)
->addTag('sonata.admin.extension', ['global' => true]);
$container
->register('sonata_extension_filter')
->setPublic(true)
->setClass($extensionClass)
->addTag('sonata.admin.extension', ['target' => 'sonata_news_admin'])
->addTag('sonata.admin.extension', ['target' => 'sonata_article_admin']);
Expand Down
11 changes: 6 additions & 5 deletions Tests/Twig/Extension/SonataAdminExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\Loader\XmlFileLoader;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass;
use Symfony\Component\Translation\Loader\XliffFileLoader;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Translator;
Expand Down Expand Up @@ -90,10 +91,6 @@ class SonataAdminExtensionTest extends TestCase

public function setUp()
{
// NEXT_MAJOR: remove this block when dropping symfony < 2.7 support
if (!class_exists('Symfony\Bridge\Twig\Extension\AssetExtension')) {
$this->markTestSkipped();
}
date_default_timezone_set('Europe/London');

$container = $this->getMockForAbstractClass('Symfony\Component\DependencyInjection\ContainerInterface');
Expand Down Expand Up @@ -121,7 +118,11 @@ public function setUp()
];

// translation extension
$translator = new Translator('en', new MessageSelector());
$translator = new Translator(
'en',
// NEXT_MAJOR: simplify this when dropping symfony < 3.4
class_exists(TranslationDumperPass::class) ? null : new MessageSelector()
);
$translator->addLoader('xlf', new XliffFileLoader());
$translator->addResource(
'xlf',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"doctrine/inflector": "^1.0",
"knplabs/knp-menu-bundle": "^2.1.1",
"sonata-project/block-bundle": "^3.2",
"sonata-project/core-bundle": "^3.4",
"sonata-project/core-bundle": "^3.6",
"sonata-project/exporter": "^1.7",
"symfony/class-loader": "^2.8 || ^3.2",
"symfony/config": "^2.8 || ^3.2",
Expand Down