From 4e6e98b54deff4ab79c83463cd49acfea6d1f5b9 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Thu, 26 Jan 2017 21:01:01 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Description/Description.php | 2 +- .../DescriptionEnhancerInterface.php | 2 +- src/Description/DescriptionFactory.php | 2 +- src/Description/Descriptor.php | 2 +- .../Enhancer/Doctrine/PhpcrOdmEnhancer.php | 8 ++--- .../Enhancer/Sonata/AdminEnhancer.php | 14 ++++---- .../Enhancer/Sylius/ResourceEnhancer.php | 17 +++++----- src/Repository/AbstractPhpcrRepository.php | 8 ++--- src/Repository/Api/EditableRepository.php | 18 +++++------ src/Repository/PhpcrOdmRepository.php | 4 +-- src/Repository/PhpcrRepository.php | 4 +-- src/Repository/Resource/CmfResource.php | 2 +- .../Resource/Metadata/PhpcrMetadata.php | 4 +-- src/Repository/Resource/PhpcrOdmResource.php | 6 ++-- src/Repository/Resource/PhpcrResource.php | 4 +-- src/RepositoryRegistryInterface.php | 2 +- .../Description/DescriptionFactoryTest.php | 4 +-- tests/Unit/Description/DescriptionTest.php | 5 ++- .../Doctrine/PhpcrOdmEnhancerTest.php | 8 ++--- .../Enhancer/Sonata/AdminEnhancerTest.php | 14 ++++---- .../Enhancer/Sylius/ResourceEnhancerTest.php | 20 ++++++------ .../AbstractPhpcrRepositoryTestCase.php | 32 +++++++++---------- .../Repository/PhpcrOdmRepositoryTest.php | 20 ++++++------ tests/Unit/Repository/PhpcrRepositoryTest.php | 12 +++---- .../Resource/Metadata/PhpcrMetadataTest.php | 26 +++++++-------- .../Resource/PhpcrOdmResourceTest.php | 2 +- .../Repository/Resource/PhpcrResourceTest.php | 2 +- 27 files changed, 121 insertions(+), 123 deletions(-) diff --git a/src/Description/Description.php b/src/Description/Description.php index ffdbfe3..632c9ae 100644 --- a/src/Description/Description.php +++ b/src/Description/Description.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Description/DescriptionEnhancerInterface.php b/src/Description/DescriptionEnhancerInterface.php index 549c7c0..4e281fd 100644 --- a/src/Description/DescriptionEnhancerInterface.php +++ b/src/Description/DescriptionEnhancerInterface.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Description/DescriptionFactory.php b/src/Description/DescriptionFactory.php index 2a5d4a2..156a8fd 100644 --- a/src/Description/DescriptionFactory.php +++ b/src/Description/DescriptionFactory.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Description/Descriptor.php b/src/Description/Descriptor.php index 5213b38..cdcce93 100644 --- a/src/Description/Descriptor.php +++ b/src/Description/Descriptor.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Description/Enhancer/Doctrine/PhpcrOdmEnhancer.php b/src/Description/Enhancer/Doctrine/PhpcrOdmEnhancer.php index b74348b..07c2f81 100644 --- a/src/Description/Enhancer/Doctrine/PhpcrOdmEnhancer.php +++ b/src/Description/Enhancer/Doctrine/PhpcrOdmEnhancer.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,13 +11,13 @@ namespace Symfony\Cmf\Component\Resource\Description\Enhancer\Doctrine; -use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; +use Doctrine\Common\Util\ClassUtils; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory; use Symfony\Cmf\Component\Resource\Description\Description; +use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory; -use Doctrine\Common\Util\ClassUtils; /** * Add descriptors from the Doctrine PHPCR ODM. diff --git a/src/Description/Enhancer/Sonata/AdminEnhancer.php b/src/Description/Enhancer/Sonata/AdminEnhancer.php index 1dfcdfc..0dc2d66 100644 --- a/src/Description/Enhancer/Sonata/AdminEnhancer.php +++ b/src/Description/Enhancer/Sonata/AdminEnhancer.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,13 +11,13 @@ namespace Symfony\Cmf\Component\Resource\Description\Enhancer\Sonata; -use Sonata\AdminBundle\Admin\Pool; use Doctrine\Common\Util\ClassUtils; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; +use Sonata\AdminBundle\Admin\Pool; use Symfony\Cmf\Component\Resource\Description\Description; +use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Add links and meta-info from Sonata Admin. @@ -59,15 +59,15 @@ public function enhance(Description $description) $class = ClassUtils::getClass($object); $admin = $this->pool->getAdminByClass($class); - $links = array(); + $links = []; $routeCollection = $admin->getRoutes(); foreach ($routeCollection->getElements() as $code => $route) { $routeName = $route->getDefault('_sonata_name'); - $url = $this->urlGenerator->generate($routeName, array( + $url = $this->urlGenerator->generate($routeName, [ $admin->getIdParameter() => $admin->getUrlsafeIdentifier($object), - ), true); + ], true); $routeRole = substr($code, strlen($admin->getCode()) + 1); diff --git a/src/Description/Enhancer/Sylius/ResourceEnhancer.php b/src/Description/Enhancer/Sylius/ResourceEnhancer.php index b572936..cc42e46 100644 --- a/src/Description/Enhancer/Sylius/ResourceEnhancer.php +++ b/src/Description/Enhancer/Sylius/ResourceEnhancer.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,18 +11,18 @@ namespace Symfony\Cmf\Component\Resource\Description\Enhancer\Sylius; +use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactory; +use Sylius\Component\Resource\Metadata\Metadata; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; use Symfony\Cmf\Component\Resource\Description\Description; -use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; +use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; +use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; -use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactory; +use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\HttpFoundation\Request; -use Sylius\Component\Resource\Metadata\Metadata; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Add descriptors from the Sylius Resource component. @@ -86,7 +86,6 @@ public function enhance(Description $description) ]; foreach ($map as $descriptor => $action) { - // note that some resources may not have routes // registered with sonata (f.e. folder resources) // so we ignore route-not-found exceptions. diff --git a/src/Repository/AbstractPhpcrRepository.php b/src/Repository/AbstractPhpcrRepository.php index 3d0f48c..0ccfc8b 100644 --- a/src/Repository/AbstractPhpcrRepository.php +++ b/src/Repository/AbstractPhpcrRepository.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -12,13 +12,13 @@ namespace Symfony\Cmf\Component\Resource\Repository; use DTL\Glob\FinderInterface; +use DTL\Glob\GlobHelper; +use Symfony\Cmf\Component\Resource\Puli\AbstractRepository; use Symfony\Cmf\Component\Resource\Puli\Api\ResourceRepository; use Symfony\Cmf\Component\Resource\Puli\ArrayResourceCollection; -use Webmozart\PathUtil\Path; -use Symfony\Cmf\Component\Resource\Puli\AbstractRepository; use Symfony\Cmf\Component\Resource\Repository\Api\EditableRepository; -use DTL\Glob\GlobHelper; use Webmozart\Assert\Assert; +use Webmozart\PathUtil\Path; /** * Abstract repository for both PHPCR and PHPCR-ODM repositories. diff --git a/src/Repository/Api/EditableRepository.php b/src/Repository/Api/EditableRepository.php index 2080e12..6c4347a 100644 --- a/src/Repository/Api/EditableRepository.php +++ b/src/Repository/Api/EditableRepository.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -28,12 +28,12 @@ interface EditableRepository extends ResourceRepository * * All resources passed to this method must implement {@link PuliResource}. * - * @param string $path The path at which to - * add the resource. - * @param PuliResource|ResourceCollection $resource The resource(s) to add - * at that path. + * @param string $path the path at which to + * add the resource + * @param PuliResource|ResourceCollection $resource the resource(s) to add + * at that path * - * @throws \InvalidArgumentException if the path is invalid. The path must + * @throws \InvalidArgumentException if the path is invalid. The path must * be a non-empty string starting with "/" * @throws \RuntimeException if the resource is invalid */ @@ -42,11 +42,11 @@ public function add($path, $resource); /** * Removes all resources matching the given query. * - * @param string $query A resource query. + * @param string $query a resource query * @param string $language The language of the query. All implementations * must support the language "glob". * - * @return int The number of resources removed from the repository. + * @return int the number of resources removed from the repository * * @throws \InvalidArgumentException if the query is invalid * @throws \RuntimeException if the language is not supported @@ -56,7 +56,7 @@ public function remove($query, $language = 'glob'); /** * Removes all resources from the repository. * - * @return int The number of resources removed from the repository. + * @return int the number of resources removed from the repository */ public function clear(); diff --git a/src/Repository/PhpcrOdmRepository.php b/src/Repository/PhpcrOdmRepository.php index 2d25be2..fcda2bb 100644 --- a/src/Repository/PhpcrOdmRepository.php +++ b/src/Repository/PhpcrOdmRepository.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -87,7 +87,7 @@ public function findByTag($tag) */ public function getTags() { - return array(); + return []; } /** diff --git a/src/Repository/PhpcrRepository.php b/src/Repository/PhpcrRepository.php index 8f31cce..9d056df 100644 --- a/src/Repository/PhpcrRepository.php +++ b/src/Repository/PhpcrRepository.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -87,7 +87,7 @@ public function findByTag($tag) */ public function getTags() { - return array(); + return []; } /** diff --git a/src/Repository/Resource/CmfResource.php b/src/Repository/Resource/CmfResource.php index 0b9fb38..316db01 100644 --- a/src/Repository/Resource/CmfResource.php +++ b/src/Repository/Resource/CmfResource.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Repository/Resource/Metadata/PhpcrMetadata.php b/src/Repository/Resource/Metadata/PhpcrMetadata.php index ab973e0..a26f4e8 100644 --- a/src/Repository/Resource/Metadata/PhpcrMetadata.php +++ b/src/Repository/Resource/Metadata/PhpcrMetadata.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Resource\Repository\Resource\Metadata; -use Symfony\Cmf\Component\Resource\Puli\Api\ResourceMetadata; use PHPCR\NodeInterface; +use Symfony\Cmf\Component\Resource\Puli\Api\ResourceMetadata; /** * Metadata for PHPCR node. diff --git a/src/Repository/Resource/PhpcrOdmResource.php b/src/Repository/Resource/PhpcrOdmResource.php index b5149df..02e8f42 100644 --- a/src/Repository/Resource/PhpcrOdmResource.php +++ b/src/Repository/Resource/PhpcrOdmResource.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Component\Resource\Repository\Resource; -use Puli\Repository\Api\Resource\Resource; +use Doctrine\Common\Util\ClassUtils; use PHPCR\DocumentInterface; use PHPCR\Util\PathHelper; -use Doctrine\Common\Util\ClassUtils; +use Puli\Repository\Api\Resource\Resource; /** * Resource representing a PHPCR document. diff --git a/src/Repository/Resource/PhpcrResource.php b/src/Repository/Resource/PhpcrResource.php index b0e266d..cd783fd 100644 --- a/src/Repository/Resource/PhpcrResource.php +++ b/src/Repository/Resource/PhpcrResource.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Resource\Repository\Resource; -use Puli\Repository\Api\Resource\Resource; use PHPCR\NodeInterface; +use Puli\Repository\Api\Resource\Resource; use Symfony\Cmf\Component\Resource\Repository\Resource\Metadata\PhpcrMetadata; /** diff --git a/src/RepositoryRegistryInterface.php b/src/RepositoryRegistryInterface.php index 2b28c97..ee0e6fb 100644 --- a/src/RepositoryRegistryInterface.php +++ b/src/RepositoryRegistryInterface.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/Unit/Description/DescriptionFactoryTest.php b/tests/Unit/Description/DescriptionFactoryTest.php index ebfc8c5..c01b898 100644 --- a/tests/Unit/Description/DescriptionFactoryTest.php +++ b/tests/Unit/Description/DescriptionFactoryTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Component\Resource\Tests\Unit\Repository; +use Prophecy\Argument; use Symfony\Cmf\Component\Resource\Description\Description; use Symfony\Cmf\Component\Resource\Description\DescriptionEnhancerInterface; -use Prophecy\Argument; use Symfony\Cmf\Component\Resource\Description\DescriptionFactory; use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; diff --git a/tests/Unit/Description/DescriptionTest.php b/tests/Unit/Description/DescriptionTest.php index c9f5f40..a63bfed 100644 --- a/tests/Unit/Description/DescriptionTest.php +++ b/tests/Unit/Description/DescriptionTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -50,14 +50,13 @@ public function testGetSet() Descriptor::TYPE_ALIAS => 'page', Descriptor::LINK_EDIT_HTML => '/path/to/edit', 'custom.key' => 'Hello', - ], $this->description->all()); } /** * It should throw an exception if a non-scalar value is set. * - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage Only scalar and array values are allowed as descriptor values, got "object" when setting descriptor "hello" */ public function testSetNonScalar() diff --git a/tests/Unit/Description/Enhancer/Doctrine/PhpcrOdmEnhancerTest.php b/tests/Unit/Description/Enhancer/Doctrine/PhpcrOdmEnhancerTest.php index 1047405..a083c6d 100644 --- a/tests/Unit/Description/Enhancer/Doctrine/PhpcrOdmEnhancerTest.php +++ b/tests/Unit/Description/Enhancer/Doctrine/PhpcrOdmEnhancerTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,13 +11,13 @@ namespace Symfony\Cmf\Component\Resource\Tests\Unit\Description\Enhancer\Doctrine; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory; use Symfony\Cmf\Component\Resource\Description\Description; -use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; use Symfony\Cmf\Component\Resource\Description\Descriptor; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory; use Symfony\Cmf\Component\Resource\Description\Enhancer\Doctrine\PhpcrOdmEnhancer; use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; -use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; +use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; class PhpcrOdmEnhancerTest extends \PHPUnit_Framework_TestCAse { diff --git a/tests/Unit/Description/Enhancer/Sonata/AdminEnhancerTest.php b/tests/Unit/Description/Enhancer/Sonata/AdminEnhancerTest.php index 90de760..2f8346a 100644 --- a/tests/Unit/Description/Enhancer/Sonata/AdminEnhancerTest.php +++ b/tests/Unit/Description/Enhancer/Sonata/AdminEnhancerTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,18 +11,18 @@ namespace Symfony\Cmf\Component\Resource\Tests\Unit\Description\Enhancer; +use Prophecy\Argument; use Sonata\AdminBundle\Admin\AbstractAdmin; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Cmf\Component\Resource\Description\Description; -use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; use Sonata\AdminBundle\Admin\Pool; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Sonata\AdminBundle\Model\AuditManagerInterface; -use Sonata\AdminBundle\Route\PathInfoBuilder; use Sonata\AdminBundle\Model\ModelManagerInterface; -use Prophecy\Argument; +use Sonata\AdminBundle\Route\PathInfoBuilder; +use Symfony\Cmf\Component\Resource\Description\Description; use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Cmf\Component\Resource\Description\Enhancer\Sonata\AdminEnhancer; +use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class SonataAdminEnhancerTest extends \PHPUnit_Framework_TestCAse { diff --git a/tests/Unit/Description/Enhancer/Sylius/ResourceEnhancerTest.php b/tests/Unit/Description/Enhancer/Sylius/ResourceEnhancerTest.php index 98dbe62..db3ffdf 100644 --- a/tests/Unit/Description/Enhancer/Sylius/ResourceEnhancerTest.php +++ b/tests/Unit/Description/Enhancer/Sylius/ResourceEnhancerTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,20 +11,20 @@ namespace Symfony\Cmf\Component\Resource\Tests\Unit\Description\Enhancer; +use Prophecy\Argument; +use Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration; +use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactory; +use Sylius\Component\Resource\Metadata\Metadata; use Sylius\Component\Resource\Metadata\RegistryInterface; +use Sylius\Component\Resource\Model\ResourceInterface; +use Symfony\Cmf\Component\Resource\Description\Description; +use Symfony\Cmf\Component\Resource\Description\Descriptor; use Symfony\Cmf\Component\Resource\Description\Enhancer\Sylius\ResourceEnhancer; -use Symfony\Component\HttpFoundation\Request; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; -use Sylius\Component\Resource\Metadata\Metadata; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactory; -use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; -use Symfony\Cmf\Component\Resource\Description\Description; -use Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration; -use Sylius\Component\Resource\Model\ResourceInterface; -use Prophecy\Argument; -use Symfony\Cmf\Component\Resource\Description\Descriptor; class ResourceEnhancerTest extends \PHPUnit_Framework_TestCAse { diff --git a/tests/Unit/Repository/AbstractPhpcrRepositoryTestCase.php b/tests/Unit/Repository/AbstractPhpcrRepositoryTestCase.php index 96ae836..4823e2b 100644 --- a/tests/Unit/Repository/AbstractPhpcrRepositoryTestCase.php +++ b/tests/Unit/Repository/AbstractPhpcrRepositoryTestCase.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -32,10 +32,10 @@ abstract public function testHasChildren($nbChildren, $hasChildren); public function provideHasChildren() { - return array( - array(2, true), - array(0, false), - ); + return [ + [2, true], + [0, false], + ]; } /** @@ -55,11 +55,11 @@ abstract public function testGet($basePath, $requestedPath, $canonicalPath, $eva public function provideGet() { - return array( - array(null, '/cmf/foobar', '/cmf/foobar', '/cmf/foobar'), - array('/site/foo.com', '/cmf/foobar', '/cmf/foobar', '/site/foo.com/cmf/foobar'), - array('/site/foo.com', '/bar/../foobar', '/foobar', '/site/foo.com/foobar'), - ); + return [ + [null, '/cmf/foobar', '/cmf/foobar', '/cmf/foobar'], + ['/site/foo.com', '/cmf/foobar', '/cmf/foobar', '/site/foo.com/cmf/foobar'], + ['/site/foo.com', '/bar/../foobar', '/foobar', '/site/foo.com/foobar'], + ]; } abstract public function testFind(); @@ -89,12 +89,12 @@ public function testGetInvalid($basePath, $requestedPath) public function provideGetInvalid() { - return array( - array(null, 'cmf/foobar'), - array(null, ''), - array(null, new \stdClass()), - array('asd', 'asd'), - ); + return [ + [null, 'cmf/foobar'], + [null, ''], + [null, new \stdClass()], + ['asd', 'asd'], + ]; } /** diff --git a/tests/Unit/Repository/PhpcrOdmRepositoryTest.php b/tests/Unit/Repository/PhpcrOdmRepositoryTest.php index 5e82710..c37c141 100644 --- a/tests/Unit/Repository/PhpcrOdmRepositoryTest.php +++ b/tests/Unit/Repository/PhpcrOdmRepositoryTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,15 +11,15 @@ namespace Symfony\Cmf\Component\Resource\Tests\Unit\Repository; -use Symfony\Cmf\Component\Resource\Puli\ArrayResourceCollection; -use Symfony\Cmf\Component\Resource\Repository\PhpcrOdmRepository; -use Symfony\Cmf\Component\Resource\Repository\Resource\PhpcrOdmResource; -use Doctrine\ODM\PHPCR\DocumentManagerInterface; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ODM\PHPCR\ChildrenCollection; +use Doctrine\ODM\PHPCR\DocumentManagerInterface; use Doctrine\ODM\PHPCR\UnitOfWork; use PHPCR\NodeInterface; use Prophecy\Argument; +use Symfony\Cmf\Component\Resource\Puli\ArrayResourceCollection; +use Symfony\Cmf\Component\Resource\Repository\PhpcrOdmRepository; +use Symfony\Cmf\Component\Resource\Repository\Resource\PhpcrOdmResource; class PhpcrOdmRepositoryTest extends AbstractPhpcrRepositoryTestCase { @@ -78,9 +78,9 @@ public function testFind() $this->documentManager->find(null, '/base/path/cmf/foobar')->willReturn($this->document); $this->uow->getDocumentId($this->document)->willReturn('/cmf/foobar'); - $this->finder->find('/base/path/cmf/*')->willReturn(array( + $this->finder->find('/base/path/cmf/*')->willReturn([ $this->document, - )); + ]); $res = $this->getRepository('/base/path')->find('/cmf/*'); @@ -98,9 +98,9 @@ public function testFind() public function testListChildren($basePath, $requestedPath, $canonicalPath, $absPath) { $this->documentManager->find(null, $absPath)->willReturn($this->document); - $this->childrenCollection->toArray()->willReturn(array( + $this->childrenCollection->toArray()->willReturn([ $this->child1, $this->child2, - )); + ]); $this->documentManager->getChildren($this->document)->willReturn($this->childrenCollection); $this->uow->getDocumentId($this->child1)->willReturn($absPath.'/child1'); $this->uow->getDocumentId($this->child2)->willReturn($absPath.'/child2'); @@ -120,7 +120,7 @@ public function testListChildren($basePath, $requestedPath, $canonicalPath, $abs */ public function testHasChildren($nbChildren, $hasChildren) { - $children = array(); + $children = []; for ($i = 0; $i < $nbChildren; ++$i) { $children[] = new \stdClass(); } diff --git a/tests/Unit/Repository/PhpcrRepositoryTest.php b/tests/Unit/Repository/PhpcrRepositoryTest.php index 7cda3a5..fa9bd2d 100644 --- a/tests/Unit/Repository/PhpcrRepositoryTest.php +++ b/tests/Unit/Repository/PhpcrRepositoryTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -55,9 +55,9 @@ public function testGet($basePath, $requestedPath, $canonicalPath, $evaluatedPat public function testFind() { $this->session->getNode('/cmf/foobar')->willReturn($this->node); - $this->finder->find('/cmf/*')->willReturn(array( + $this->finder->find('/cmf/*')->willReturn([ $this->node, - )); + ]); $res = $this->getRepository()->find('/cmf/*'); @@ -75,9 +75,9 @@ public function testFind() public function testListChildren($basePath, $requestedPath, $canonicalPath, $absPath) { $this->session->getNode($absPath)->willReturn($this->node); - $this->node->getNodes()->willReturn(array( + $this->node->getNodes()->willReturn([ $this->node1, $this->node2, - )); + ]); $this->node1->getPath()->willReturn($absPath.'/node1'); $this->node2->getPath()->willReturn($absPath.'/node2'); @@ -108,7 +108,7 @@ public function testGetNotExisting() */ public function testHasChildren($nbChildren, $hasChildren) { - $children = array(); + $children = []; for ($i = 0; $i < $nbChildren; ++$i) { $children[] = $this->prophesize('PHPCR\NodeInterface'); } diff --git a/tests/Unit/Repository/Resource/Metadata/PhpcrMetadataTest.php b/tests/Unit/Repository/Resource/Metadata/PhpcrMetadataTest.php index d4e953a..71862f7 100644 --- a/tests/Unit/Repository/Resource/Metadata/PhpcrMetadataTest.php +++ b/tests/Unit/Repository/Resource/Metadata/PhpcrMetadataTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -40,47 +40,47 @@ public function testMethods($method, $mixinType, $hasMixin, $propertyName, $prop public function provideMethods() { - return array( - array( + return [ + [ 'getCreationTime', 'mix:created', true, 'jcr:created', new \DateTime('2015-01-01T00:00:00Z'), 1420070400, - ), - array( + ], + [ 'getModificationTime', 'mix:lastModified', true, 'jcr:lastModified', new \DateTime('2015-01-01T00:00:00Z'), 1420070400, - ), - array( + ], + [ 'getCreationTime', 'mix:created', false, null, null, 0, - ), - array( + ], + [ 'getModificationTime', 'mix:lastModified', false, null, null, 0, - ), - array( + ], + [ 'getAccessTime', null, null, null, null, 0, - ), - ); + ], + ]; } } diff --git a/tests/Unit/Repository/Resource/PhpcrOdmResourceTest.php b/tests/Unit/Repository/Resource/PhpcrOdmResourceTest.php index 788c9f4..8e7d653 100644 --- a/tests/Unit/Repository/Resource/PhpcrOdmResourceTest.php +++ b/tests/Unit/Repository/Resource/PhpcrOdmResourceTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/Unit/Repository/Resource/PhpcrResourceTest.php b/tests/Unit/Repository/Resource/PhpcrResourceTest.php index 81d7d5d..bf19183 100644 --- a/tests/Unit/Repository/Resource/PhpcrResourceTest.php +++ b/tests/Unit/Repository/Resource/PhpcrResourceTest.php @@ -3,7 +3,7 @@ /* * This file is part of the Symfony CMF package. * - * (c) 2011-2015 Symfony CMF + * (c) 2011-2017 Symfony CMF * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code.