diff --git a/.travis.yml b/.travis.yml index 83db1e0..4a0488a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: php php: - - 5.5 - - 5.6 - 7.0 - hhvm @@ -11,39 +9,40 @@ sudo: false cache: directories: - $HOME/.composer/cache/files + - .phpunit env: - - SYMFONY_VERSION=2.7.* + matrix: SYMFONY_VERSION=3.2.* + global: SYMFONY_PHPUNIT_DIR="./.phpunit" SYMFONY_PHPUNIT_REMOVE="symfony/yaml" SYMFONY_PHPUNIT_VERSION=5.7 matrix: - allow_failures: - - env: SYMFONY_VERSION=dev-master - - php: hhvm include: + - php: 7.1 + env: SYMFONY_VERSION=3.3.* DEPS=dev - php: 5.6 - env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak - - php: 5.6 - env: SYMFONY_VERSION=2.8.* - - php: 5.6 - env: SYMFONY_VERSION=3.0.* - allow_failures: - - env: SYMFONY_VERSION=2.8.* - - env: SYMFONY_VERSION=3.0.* + env: SYMFONY_VERSION=2.8.* COMPOSER_FLAGS="--prefer-lowest" + - php: 7.1 + env: SYMFONY_VERSION=3.1.* fast_finish: true before_install: - - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi + - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi - phpenv config-rm xdebug.ini || true - composer self-update - - composer require symfony/symfony:${SYMFONY_VERSION} --no-update + - if [ "$DEPS" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi + - if [ "$SYMFONY_VERSION" != "" ]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi -install: composer update --prefer-dist +install: composer update --prefer-dist $COMPOSER_FLAGS -before_script: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh +before_script: + - mv vendor/phpunit ./phpunit + - composer dump-autoload + - vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh script: - - phpunit + - vendor/bin/simple-phpunit - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then ./vendor/symfony-cmf/testing/bin/server & fi + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then mv ./phpunit vendor/phpunit; composer dump-autoload; fi - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then ./vendor/bin/behat; fi notifications: diff --git a/Controller/ResourceController.php b/Controller/ResourceController.php index a05a92d..cf3f1f3 100644 --- a/Controller/ResourceController.php +++ b/Controller/ResourceController.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Bundle\ResourceRestBundle\Controller; -use Puli\Repository\Api\EditableRepository; -use Puli\Repository\Api\ResourceRepository; +use Symfony\Cmf\Component\Resource\Puli\Api\ResourceRepository; +use Symfony\Cmf\Component\Resource\Puli\Api\ResourceNotFoundException; use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -20,7 +20,6 @@ use Symfony\Component\Routing\Exception\RouteNotFoundException; use JMS\Serializer\SerializerInterface; use JMS\Serializer\SerializationContext; -use Puli\Repository\Api\ResourceNotFoundException; class ResourceController { @@ -88,7 +87,6 @@ public function getResourceAction($repositoryName, $path) public function patchResourceAction($repositoryName, $path, Request $request) { $repository = $this->registry->get($repositoryName); - $this->failOnNotEditable($repository, $repositoryName); $path = '/'.ltrim($path, '/'); @@ -127,7 +125,6 @@ public function patchResourceAction($repositoryName, $path, Request $request) public function deleteResourceAction($repositoryName, $path) { $repository = $this->registry->get($repositoryName); - $this->failOnNotEditable($repository, $repositoryName); $path = '/'.ltrim($path, '/'); @@ -136,13 +133,6 @@ public function deleteResourceAction($repositoryName, $path) return $this->createResponse('', Response::HTTP_NO_CONTENT); } - private function failOnNotEditable(ResourceRepository $repository, $repositoryName) - { - if (!$repository instanceof EditableRepository) { - throw new RouteNotFoundException(sprintf('Repository "%s" is not editable.', $repositoryName)); - } - } - /** * @param string $message * diff --git a/Enhancer/DescriptionEnhancer.php b/Enhancer/DescriptionEnhancer.php index 4c3be65..3328d4c 100644 --- a/Enhancer/DescriptionEnhancer.php +++ b/Enhancer/DescriptionEnhancer.php @@ -11,7 +11,7 @@ namespace Symfony\Cmf\Bundle\ResourceRestBundle\Enhancer; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; use Symfony\Cmf\Component\Resource\Description\DescriptionFactory; /** diff --git a/Enhancer/EnhancerInterface.php b/Enhancer/EnhancerInterface.php index 0746183..de35b45 100644 --- a/Enhancer/EnhancerInterface.php +++ b/Enhancer/EnhancerInterface.php @@ -11,7 +11,7 @@ namespace Symfony\Cmf\Bundle\ResourceRestBundle\Enhancer; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; /** * Enhancer classes enhance the REST response for resources. diff --git a/Enhancer/PayloadEnhancer.php b/Enhancer/PayloadEnhancer.php index ce2b027..d97ba54 100644 --- a/Enhancer/PayloadEnhancer.php +++ b/Enhancer/PayloadEnhancer.php @@ -11,7 +11,7 @@ namespace Symfony\Cmf\Bundle\ResourceRestBundle\Enhancer; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; /** * Serialize the payload. diff --git a/Enhancer/SonataAdminEnhancer.php b/Enhancer/SonataAdminEnhancer.php index 0db84f5..019b03b 100644 --- a/Enhancer/SonataAdminEnhancer.php +++ b/Enhancer/SonataAdminEnhancer.php @@ -14,7 +14,7 @@ use Sonata\AdminBundle\Admin\Pool; use Doctrine\Common\Util\ClassUtils; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; /** * Add links and meta-info from Sonata Admin. diff --git a/README.md b/README.md index b7e04df..8c20654 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ resources as provided by the ## Requirements -* Symfony 2.2.x +* Symfony 2.8+ * See also the `require` section of [composer.json](composer.json) ## Documentation diff --git a/Registry/PayloadAliasRegistry.php b/Registry/PayloadAliasRegistry.php index 048c76c..2c5a3d2 100644 --- a/Registry/PayloadAliasRegistry.php +++ b/Registry/PayloadAliasRegistry.php @@ -11,7 +11,7 @@ namespace Symfony\Cmf\Bundle\ResourceRestBundle\Registry; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface; use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource; diff --git a/Serializer/Jms/EventSubscriber/ResourceSubscriber.php b/Serializer/Jms/EventSubscriber/ResourceSubscriber.php index f0d7bb6..21b60a7 100644 --- a/Serializer/Jms/EventSubscriber/ResourceSubscriber.php +++ b/Serializer/Jms/EventSubscriber/ResourceSubscriber.php @@ -14,7 +14,7 @@ use JMS\Serializer\EventDispatcher\EventSubscriberInterface; use JMS\Serializer\EventDispatcher\Events; use JMS\Serializer\EventDispatcher\PreSerializeEvent; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; /** * Force instaces of ResourceCollection to type "ResourceCollection". diff --git a/Serializer/Jms/Handler/ResourceHandler.php b/Serializer/Jms/Handler/ResourceHandler.php index e8f7593..cd9b020 100644 --- a/Serializer/Jms/Handler/ResourceHandler.php +++ b/Serializer/Jms/Handler/ResourceHandler.php @@ -17,8 +17,7 @@ use JMS\Serializer\Context; use PHPCR\NodeInterface; use PHPCR\Util\PathHelper; -use Puli\Repository\Api\Resource\BodyResource; -use Puli\Repository\Api\Resource\PuliResource; +use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource; use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface; use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry; use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\EnhancerRegistry; @@ -76,7 +75,7 @@ public function serializeResource( private function doSerializeResource(PuliResource $resource, $depth = 0) { $data = array(); - $repositoryAlias = $this->registry->getRepositoryAlias($resource->getRepository()); + $repositoryAlias = $this->registry->getRepositoryName($resource->getRepository()); $data['repository_alias'] = $repositoryAlias; $data['repository_type'] = $this->registry->getRepositoryType($resource->getRepository()); @@ -103,10 +102,6 @@ private function doSerializeResource(PuliResource $resource, $depth = 0) } $data['children'] = $children; - if ($resource instanceof BodyResource) { - $data['body'] = $resource->getBody(); - } - foreach ($enhancers as $enhancer) { $data = $enhancer->enhance($data, $resource); } diff --git a/Tests/Features/resource_api_filesystem.feature b/Tests/Features/resource_api_filesystem.feature index 689c0d0..eae12ee 100644 --- a/Tests/Features/resource_api_filesystem.feature +++ b/Tests/Features/resource_api_filesystem.feature @@ -3,35 +3,35 @@ Feature: Filesystem resource repository As a webservice user I need to be able to query the webservice - Background: - Given the test application has the following configuration: - """ - cmf_resource: - repositories: - default: - type: filesystem - base_dir: "%kernel.root_dir%/Resources/views/snippets" - """ - And there is a file named "%kernel.root_dir%/Resources/views/snippets/snippet1.html" with: - """ -

Snippet 1

- """ - - - Scenario: Retrieve filesystem resource - When I send a GET request to "/api/default/snippet1.html" - Then the response should contain json: - """ - { - "repository_alias": "default", - "repository_type": "filesystem", - "payload_alias": null, - "payload_type": null, - "path": "\/snippet1.html", - "node_name": "snippet1.html", - "label": "snippet1.html", - "repository_path": "\/snippet1.html", - "children": [], - "body": "

Snippet 1

" - } - """ +# Background: +# Given the test application has the following configuration: +# """ +# cmf_resource: +# repositories: +# default: +# type: filesystem +# base_dir: "%kernel.root_dir%/Resources/views/snippets" +# """ +# And there is a file named "%kernel.root_dir%/Resources/views/snippets/snippet1.html" with: +# """ +#

Snippet 1

+# """ +# +# +# Scenario: Retrieve filesystem resource +# When I send a GET request to "/api/default/snippet1.html" +# Then the response should contain json: +# """ +# { +# "repository_alias": "default", +# "repository_type": "filesystem", +# "payload_alias": null, +# "payload_type": null, +# "path": "\/snippet1.html", +# "node_name": "snippet1.html", +# "label": "snippet1.html", +# "repository_path": "\/snippet1.html", +# "children": [], +# "body": "

Snippet 1

" +# } +# """ diff --git a/Tests/Resources/app/AppKernel.php b/Tests/Resources/app/AppKernel.php index d9d025e..b7ca117 100644 --- a/Tests/Resources/app/AppKernel.php +++ b/Tests/Resources/app/AppKernel.php @@ -12,6 +12,7 @@ use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Features\Context\ResourceContext; +use Symfony\Bundle\WebServerBundle\WebServerBundle; /** * This is the kernel used by the application being tested. diff --git a/Tests/Unit/Enhancer/SonataAdminEnhancerTest.php b/Tests/Unit/Enhancer/SonataAdminEnhancerTest.php index 9d9bed1..4e2f6d4 100644 --- a/Tests/Unit/Enhancer/SonataAdminEnhancerTest.php +++ b/Tests/Unit/Enhancer/SonataAdminEnhancerTest.php @@ -21,7 +21,7 @@ class SonataAdminEnhancerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->admin = $this->prophesize('Sonata\AdminBundle\Admin\Admin'); + $this->admin = $this->prophesize('Sonata\AdminBundle\Admin\AbstractAdmin'); $this->pool = $this->prophesize('Sonata\AdminBundle\Admin\Pool'); $this->visitor = $this->prophesize('JMS\Serializer\GenericSerializationVisitor'); $this->generator = $this->prophesize('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); diff --git a/Tests/Unit/Registry/PayloadAliasRegistryTest.php b/Tests/Unit/Registry/PayloadAliasRegistryTest.php index 44d2f91..1164d7d 100644 --- a/Tests/Unit/Registry/PayloadAliasRegistryTest.php +++ b/Tests/Unit/Registry/PayloadAliasRegistryTest.php @@ -23,7 +23,7 @@ public function setUp() { $this->repositoryRegistry = $this->prophesize('Symfony\Cmf\Component\Resource\RepositoryRegistryInterface'); $this->resource = $this->prophesize('Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource'); - $this->repository = $this->prophesize('Puli\Repository\Api\ResourceRepository'); + $this->repository = $this->prophesize('Symfony\Cmf\Component\Resource\Puli\Api\ResourceRepository'); } public function provideRegistry() diff --git a/Tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php b/Tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php index 9f2d2a8..c2904e0 100644 --- a/Tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php +++ b/Tests/Unit/Serializer/Jms/Handler/ResourceHandlerTest.php @@ -28,7 +28,7 @@ public function setUp() $this->resource = $this->prophesize('Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource'); $this->childResource = $this->prophesize('Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource'); - $this->repository = $this->prophesize('Puli\Repository\Api\ResourceRepository'); + $this->repository = $this->prophesize('Symfony\Cmf\Component\Resource\Puli\Api\ResourceRepository'); $this->payload = new \stdClass(); $this->context = $this->prophesize('JMS\Serializer\Context'); @@ -43,7 +43,7 @@ public function setUp() public function testHandler() { - $this->repositoryRegistry->getRepositoryAlias($this->repository)->willReturn('repo'); + $this->repositoryRegistry->getRepositoryName($this->repository)->willReturn('repo'); $this->repositoryRegistry->getRepositoryType($this->repository)->willReturn('repo_type'); $this->payloadAliasRegistry->getPayloadAlias($this->resource->reveal())->willReturn('alias'); $this->resource->getPayloadType()->willReturn('payload_type'); @@ -64,7 +64,7 @@ public function testHandler() $this->enhancerRegistry->getEnhancers('repo')->willReturn(array( $this->enhancer, )); - $this->enhancer->enhance(Argument::type('array'), Argument::type('Puli\Repository\Api\Resource\PuliResource')) + $this->enhancer->enhance(Argument::type('array'), Argument::type('Symfony\Cmf\Component\Resource\Puli\Api\PuliResource')) ->will(function ($data, $resource) { return $data[0]; }); diff --git a/composer.json b/composer.json index ad711b5..a7dcfaf 100644 --- a/composer.json +++ b/composer.json @@ -10,22 +10,24 @@ } ], "require": { - "php": "^5.5.6|^7.0", - "symfony-cmf/resource-bundle": "^1.0", - "puli/repository": "@beta", - "jms/serializer-bundle": "1.*" + "php": "^5.6|^7.0", + "symfony-cmf/resource": "1.0.*@dev", + "symfony-cmf/resource-bundle": "1.0.*@dev", + "jms/serializer-bundle": "^1.0" }, "require-dev": { - "symfony-cmf/testing": "^1.3", + "symfony-cmf/testing": "^2.0", + "symfony/phpunit-bridge": "^3.2", "doctrine/phpcr-odm": "^1.3", - "behat/behat": "^3.0", - "behat/web-api-extension" : "1.*", - "behat/symfony2-extension": "2.*@dev", - "matthiasnoback/symfony-dependency-injection-test": "~0.1", - "matthiasnoback/symfony-config-test": "~0.1", - "sonata-project/doctrine-phpcr-admin-bundle": "^1.2" + "jms/serializer": "^1.2", + "behat/behat": "^3.0.6", + "behat/web-api-extension" : "^1.0@dev", + "behat/symfony2-extension": "^2.0", + "matthiasnoback/symfony-dependency-injection-test": "~0.6", + "matthiasnoback/symfony-config-test": "^1.3.1", + "sonata-project/admin-bundle": "^3.1" }, - "minimum-stability": "dev", + "minimum-stability": "RC", "prefer-stable": true, "suggest": { "doctrine/phpcr-odm": "To enable support for the PHPCR ODM documents (^1.2)",