Permalink
Browse files

add new article api resource, fix api image updating, add behat tests

  • Loading branch information...
ahilles107 committed Dec 2, 2014
1 parent 98b227a commit a2f9b61ca10b36b1f1f016e55038a94cc2b15e12
Showing with 2,655 additions and 1,616 deletions.
  1. +2 −4 .travis.yml
  2. +14 −2 behat.yml
  3. +50 −0 features/0_api_articles.feature
  4. +55 −0 features/1_api_images.feature
  5. +60 −0 features/2_api_linkImage_to_article.feature
  6. +144 −222 features/bootstrap/FeatureContext.php
  7. +663 −0 features/bootstrap/RestContext.php
  8. +0 −675 newscoop/COPYING.txt
  9. +3 −0 newscoop/application/configs/services/services.yml
  10. +6 −0 newscoop/application/configs/symfony/config.yml
  11. +0 −4 newscoop/application/configs/symfony/routing.yml
  12. +1 −8 newscoop/application/configs/symfony/security.yml
  13. +1 −0 newscoop/application/console
  14. +6 −1 newscoop/application/controllers/AuthController.php
  15. +0 −96 newscoop/application/controllers/LegacyController.php
  16. +0 −2 newscoop/classes/ArticleIndex.php
  17. +9 −1 newscoop/classes/Statistics.php
  18. +2 −1 newscoop/composer.json
  19. +164 −161 newscoop/composer.lock
  20. +3 −0 newscoop/include/smarty/campsite_plugins/block.assetic.php
  21. +1 −1 newscoop/index.php
  22. +6 −2 newscoop/install/Resources/sql/campsite_core.sql
  23. +6 −2 newscoop/install/Resources/sql/campsite_demo_tables.sql
  24. +2 −3 newscoop/install/Resources/sql/upgrade/4.4.x/2014.11.05/tables.sql
  25. +3 −0 newscoop/install/Resources/sql/upgrade/4.4.x/2014.11.22/tables.sql
  26. +9 −0 newscoop/library/Newscoop/Article/LinkService.php
  27. +2 −2 newscoop/library/Newscoop/Entity/Aliases.php
  28. +292 −28 newscoop/library/Newscoop/Entity/Article.php
  29. +2 −1 newscoop/library/Newscoop/Entity/AuthorType.php
  30. +52 −0 newscoop/library/Newscoop/Entity/Repository/ArticleRepository.php
  31. +12 −0 newscoop/library/Newscoop/Entity/Repository/AutoIdRepository.php
  32. +5 −0 newscoop/library/Newscoop/Entity/Repository/IssueRepository.php
  33. +3 −6 newscoop/library/Newscoop/Entity/Repository/LanguageRepository.php
  34. +3 −3 newscoop/library/Newscoop/Entity/User.php
  35. +9 −17 newscoop/library/Newscoop/Image/ImageService.php
  36. +1 −1 newscoop/library/Newscoop/Installer/Services/DatabaseService.php
  37. +124 −0 newscoop/library/Newscoop/Services/ArticleService.php
  38. +47 −2 newscoop/library/Newscoop/Services/UserService.php
  39. +1 −1 newscoop/library/Newscoop/Tools/Console/Command/CreateOAuthClientCommand.php
  40. +58 −0 newscoop/library/Newscoop/Tools/Console/Command/CreateUserCommand.php
  41. +46 −0 newscoop/library/Newscoop/User/UserManager.php
  42. +0 −20 newscoop/phpunit.xml
  43. +142 −279 newscoop/src/Newscoop/GimmeBundle/Controller/ArticlesController.php
  44. +11 −11 newscoop/src/Newscoop/GimmeBundle/Controller/ImagesController.php
  45. +0 −27 newscoop/src/Newscoop/GimmeBundle/EventListener/OverrideMethodListener.php
  46. +86 −0 newscoop/src/Newscoop/GimmeBundle/Form/Type/ArticleFieldsType.php
  47. +45 −3 newscoop/src/Newscoop/GimmeBundle/Form/Type/ArticleType.php
  48. +23 −0 newscoop/src/Newscoop/GimmeBundle/Form/Type/ImageType.php
  49. +0 −5 newscoop/src/Newscoop/GimmeBundle/Resources/config/services.yml
  50. +3 −1 newscoop/src/Newscoop/NewscoopBundle/EventListener/AuthenticationListener.php
  51. +8 −3 newscoop/src/Newscoop/NewscoopBundle/Menu/Builder.php
  52. +7 −1 newscoop/src/Newscoop/NewscoopBundle/Twig/NewscoopExtension.php
  53. 0 {features → old_features}/0_endpoints.feature.unfinished
  54. 0 {features → old_features}/10_images.feature
  55. 0 {features → old_features}/11_attachments.feature
  56. 0 {features → old_features}/12_snippet.feature
  57. 0 {features → old_features}/1_article.feature
  58. 0 {features → old_features}/2_author.feature
  59. 0 {features → old_features}/3_comments.feature
  60. 0 {features → old_features}/4_user.feature
  61. 0 {features → old_features}/5_topic.feature
  62. 0 {features → old_features}/6_slideshow.feature
  63. 0 {features → old_features}/7_section.feature
  64. 0 {features → old_features}/8_articles_lists.feature
  65. 0 {features → old_features}/99_functions.feature
  66. +314 −0 old_features/bootstrap/FeatureContext.php
  67. 0 {features → old_features}/bootstrap/PublicationListener.php
  68. BIN {features → old_features}/bootstrap/assets/picture.jpg
  69. +0 −19 phpunit.xml.dist
  70. +127 −1 spec/Newscoop/GimmeBundle/Controller/ArticlesControllerSpec.php
  71. +22 −0 spec/Newscoop/Services/ArticleServiceSpec.php
@@ -20,11 +20,9 @@ before_script:
- mysql -e 'create database newscoop;' -uroot
- cd newscoop/
- composer install --prefer-dist
- "./application/console newscoop:install --fix --database_name newscoop --database_user
root"
- "./application/console newscoop:install --fix --database_name newscoop --database_user root"
- sudo php upgrade.php
- "./application/console oauth:create-client testclient newscoop.dev newscoop.dev
--test"
- "./application/console oauth:create-client testclient newscoop.dev newscoop.dev --test"
- cd ..
- sudo php newscoop/scripts/fixer.php
script:
@@ -1,6 +1,18 @@
default:
paths:
features: %behat.paths.base%/features
bootstrap: %behat.paths.features%/bootstrap
filters:
context:
parameters:
base_url: http://newscoop.dev/api
oauth_url: http://newscoop.dev/oauth
publication: newscoop.dev
api_prefix: api
base_url: http://newscoop.dev/api/
publication: newscoop.dev
paths:
base: %behat.paths.base%
bootstrap: features/bootstrap
steps: features/steps
hooks: features/support
subContexts:
associative: true
@@ -0,0 +1,50 @@
Feature: Endpoints
I need to be able to read api informations
Scenario: Check if route is correct
Given that I want to find an articles
When I request "/articles"
And the response is JSON
Scenario: Create new article
Given that I want to create an new article
And that i have fake "article" data:
| name | <<sentence>> | 4 |
| language | 1 ||
| publication | 1 ||
| issue | ||
| section | ||
| comments_enabled | 1 ||
| type | news ||
| onFrontPage | 0 ||
| onSection | 0 ||
| keywords | <<text>> | 30 |
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I submit "article" data to "/articles/create"
Then the response status code should be 201
And the response is JSON
And the response should contain field "number"
And the response should contain field "title"
And the response should contain field "type"
Then save new item location as "new_article"
Given that I want to create an new article
And that i have fake "article" data:
| name | <<sentence>> | 4 |
| language | 1 ||
| publication | 1 ||
| issue | ||
| section | ||
| comments_enabled | 1 ||
| type | news ||
| onFrontPage | 1 ||
| onSection | 1 ||
| keywords | test keywords | 30 |
| fields[lead] | <<sentence>> | 15 |
| fields[content] | <<sentence>> | 35 |
When I submit "article" data to "<<new_article>>"
Then the response status code should be 200
And the response is JSON
And field "keywords" in the response should be "test keywords"
@@ -0,0 +1,55 @@
Feature: Images
I need to be able to work with images api
Scenario: Check if route is correct
Given that I want to find an articles
When I request "/images"
And the response is JSON
Scenario: Create new image
Given that I want to create an new image
And that i have fake "image" data:
| description | <<sentence>> | 6 |
| photographer | <<name>> | |
| photographer_url | <<url>> | |
| place | <<address>> | |
| image | <<image>> | /tmp,640,480 |
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I submit "image" data to "/images"
Then the response status code should be 201
And the response is JSON
And the response should contain field "photographer"
And the response should contain field "photographerUrl"
And the response should contain field "description"
Then save new item location as "new_image"
Given that I want to find an article
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I request "<<new_image>>"
Then the response status code should be 200
And the response is JSON
And the response should contain field "photographer"
And the response should contain field "photographerUrl"
And the response should contain field "description"
Given that I want to create an new image
And that i have fake "image" data:
| description | <<sentence>> | 12 |
| photographer | <<name>> | |
| photographer_url | <<url>> | |
| place | <<address>> | |
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I submit "image" data to "<<new_image>>"
Then the response status code should be 200
And the response is JSON
And the response should contain field "photographer"
And the response should contain field "photographerUrl"
And the response should contain field "description"
Given that I want to delete an image
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I request "<<new_image>>"
Then the response status code should be 204
And the response is JSON
@@ -0,0 +1,60 @@
Feature: Images
I need to be able to work link images to articles
Scenario: Create new article and image
Given that I want to create an new article
And that i have fake "article" data:
| name | <<sentence>> | 4 |
| language | 1 ||
| publication | 1 ||
| issue | ||
| section | ||
| comments_enabled | 1 ||
| type | news ||
| onFrontPage | 0 ||
| onSection | 0 ||
| keywords | <<text>> | 30 |
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I submit "article" data to "/articles/create"
Then the response status code should be 201
And the response is JSON
And the response should contain field "number"
And the response should contain field "title"
And the response should contain field "type"
Then save new item location as "new_article"
Given that I want to create an new image
And that i have fake "image" data:
| description | <<sentence>> | 6 |
| photographer | <<name>> | |
| photographer_url | <<url>> | |
| place | <<address>> | |
| image | <<image>> | /tmp,640,480 |
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I submit "image" data to "/images"
Then the response status code should be 201
And the response is JSON
And the response should contain field "photographer"
And the response should contain field "photographerUrl"
And the response should contain field "description"
Then save new item location as "new_image"
Given that I want to link an image to article
And that i have "link" header with "<$$new_image$$; rel='image'>" value
When I request "<<new_article>>"
Then the response status code should be 201
And the response is JSON
Given that I want to unlink an image from article
And that i have "link" header with "<$$new_image$$; rel='image'>" value
When I request "<<new_article>>"
Then the response status code should be 204
And the response is JSON
Given that I want to delete an image
And I'm logged in as "testuser" with "testpassword" with client "1_svdg45ew371vtsdgd29fgvwe5v" and secret "h48fgsmv0due4nexjsy40jdf3sswwr"
When I request "<<new_image>>"
Then the response status code should be 204
And the response is JSON
Oops, something went wrong.

0 comments on commit a2f9b61

Please sign in to comment.