-
Notifications
You must be signed in to change notification settings - Fork 32
[WIP] first steps to an RESTController by the help of sylius resource-bundle #144
Changes from all commits
160efec
b5aa79f
19a3dc9
2ad7f26
728e6e6
6940d5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| namespace Symfony\Cmf\Bundle\ContentBundle\Form\Type; | ||
|
|
||
| use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; | ||
| use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
| use Symfony\Component\Form\FormBuilderInterface; | ||
|
|
||
| /** | ||
| * @author Maximilian Berghoff <Maximilian.Berghoff@mayflower.de> | ||
| */ | ||
| class StaticContent extends AbstractResourceType | ||
| { | ||
| public function buildForm(FormBuilderInterface $builder, array $options) | ||
| { | ||
| $builder->add('title', TextType::class); | ||
| $builder->add('body', TextType::class); | ||
| } | ||
|
|
||
| public function getName() | ||
| { | ||
| return 'cmf_static_content'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Symfony\Cmf\Bundle\ContentBundle\Model\StaticContent: | ||
| exclusion_policy: ALL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| INDEX |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "title": "My new title", | ||
| "body": "My new body" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "title": "My new title", | ||
| "body": "My new body" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CREATE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| INDEX |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| UPDATE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| cmf_static_content_index: | ||
| path: "/collection" | ||
| defaults: {_controller: "cmf.controller.static_content:indexAction" } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony CMF package. | ||
| * | ||
| * (c) 2011-2015 Symfony CMF | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Cmf\Bundle\ContentBundle\Tests\WebTest\Controller; | ||
|
|
||
| use Symfony\Cmf\Component\Testing\Functional\BaseTestCase; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| /** | ||
| * @author Maximilian Berghoff <Maximilian.Berghoff@mayflower.de> | ||
| */ | ||
| class RESTContentControllerTest extends BaseTestCase | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RestContent
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently not sure if i should switch to behat tests as you did on resource-rest-bundle. So maybe that test will disappear. |
||
| { | ||
| public function setUp() | ||
| { | ||
| $this->db('PHPCR')->loadFixtures(array( | ||
| 'Symfony\Cmf\Bundle\ContentBundle\Tests\Resources\DataFixtures\Phpcr\LoadContentData', | ||
| )); | ||
| $this->client = $this->createClient(); | ||
| } | ||
|
|
||
| public function testGET() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. testGet |
||
| { | ||
| $this->client->request('GET', '/content-1', array(), array(), array('ACCEPT'=> 'application/json')); | ||
| $res = $this->client->getResponse(); | ||
| $this->assertEquals(200, $res->getStatusCode()); | ||
| } | ||
|
|
||
| public function testPUT() | ||
| { | ||
| $this->client->request( | ||
| 'PUT', | ||
| '/content-1', | ||
| array(), | ||
| array(), | ||
| array('ACCEPT'=> 'application/json', 'CONTENT_TYPE' => 'application/json'), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the ACCEPT header isn't currently recoginzed by sylius. even with FOSRest format listener. |
||
| file_get_contents(__DIR__ . '/../../Resources/Fixtures/json/put.json') | ||
| ); | ||
| $res = $this->client->getResponse(); | ||
| $this->assertEquals(Response::HTTP_OK, $res->getStatusCode()); | ||
| } | ||
|
|
||
| public function testDELETE() | ||
| { | ||
| $this->client->request( | ||
| 'DELETE', | ||
| '/content-1', | ||
| array(), | ||
| array(), | ||
| array('ACCEPT'=> 'application/json') | ||
| ); | ||
| $res = $this->client->getResponse(); | ||
| $this->assertEquals(Response::HTTP_FOUND, $res->getStatusCode()); | ||
| } | ||
|
|
||
| public function testPOST() | ||
| { | ||
| $this->client->request( | ||
| 'POST', | ||
| '/collection', | ||
| array(), | ||
| array(), | ||
| array('ACCEPT'=> 'application/json', 'CONTENT_TYPE' => 'application/json'), | ||
| file_get_contents(__DIR__ . '/../../Resources/Fixtures/json/post.json') | ||
| ); | ||
| $res = $this->client->getResponse(); | ||
| $this->assertEquals(Response::HTTP_OK, $res->getStatusCode()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,17 +11,34 @@ | |
| "homepage": "https://github.com/symfony-cmf/ContentBundle/contributors" | ||
| } | ||
| ], | ||
| "repositories": [ | ||
| { | ||
| "type": "vcs", | ||
| "url": "https://github.com/ElectricMaxxx/RestBundle.git" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used my own simple method aware enhancer in that little test repo. |
||
| }, | ||
| { | ||
| "type": "path", | ||
| "url": "https://github.com/dantleech/Sylius/tree/phpcrodm_form_builder/src/Sylius/Bundle/ResourceBundle", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My try to get the branch of @dantleech but does not work that way.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dantleech you know what would be the right solution. Tried several options:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if there is one. You can just run the tests locally use a symlink - On Mon, May 30, 2016 at 06:03:34AM -0700, Maximilian Berghoff wrote:
|
||
| "options": { | ||
| "symlink": false | ||
| } | ||
| } | ||
| ], | ||
| "minimum-stability": "dev", | ||
| "require": { | ||
| "php": "^5.3.9|^7.0", | ||
| "symfony/framework-bundle": "^2.3|3.*", | ||
| "symfony-cmf/core-bundle": "^1.1", | ||
| "symfony-cmf/menu-bundle": "^1.1|2.*", | ||
| "symfony-cmf/routing-bundle": "^1.2" | ||
| "symfony-cmf/routing-bundle": "^1.2", | ||
| "sylius/resource-bundle": "^0.18", | ||
| "doctrine/orm": "^2.4.8,<2.5" | ||
| }, | ||
| "require-dev": { | ||
| "symfony-cmf/testing": "^1.3", | ||
| "sonata-project/doctrine-phpcr-admin-bundle": "^1.1", | ||
| "symfony/monolog-bundle": "^2.3" | ||
| "symfony/monolog-bundle": "^2.3", | ||
| "electricmaxxx/rest-bundle":"dev-master" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will be removed, when routing is ready to do its job. |
||
| }, | ||
| "suggest": { | ||
| "friendsofsymfony/rest-bundle": "Improved handling for different output formats", | ||
|
|
@@ -39,5 +56,8 @@ | |
| "branch-alias": { | ||
| "dev-master": "2.0-dev" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "post:update":"rm -rf vendor/sylius/resource-bundle/" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created for the redirect defintion after delete only. Should be done in a kind of an route enhancer to pass the information by class.