Skip to content

Commit

Permalink
add new article api resource, fix api image updating, add behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahilles107 committed Dec 2, 2014
1 parent 98b227a commit a2f9b61
Show file tree
Hide file tree
Showing 71 changed files with 2,655 additions and 1,616 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 14 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions features/0_api_articles.feature
Original file line number Diff line number Diff line change
@@ -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"
55 changes: 55 additions & 0 deletions features/1_api_images.feature
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions features/2_api_linkImage_to_article.feature
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit a2f9b61

Please sign in to comment.