at the end of the day, it was inevitable

This commit is contained in:
Mo Elzubeir
2022-12-09 08:36:26 -06:00
commit 1218570914
1768 changed files with 887087 additions and 0 deletions
@@ -0,0 +1,78 @@
Feature: Create category
As an authenticated user
I should able to create new category
@db-fixtures
Scenario:
I try to create new category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
"name": "new category",
"parent": 4
}
"""
Then I got successful response
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('name', 'new category')
"""
Scenario:
I try to create new category but not provide name.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value should not be blank.",
"transKey": "createCategoryNameEmpty",
"type": "error",
"parameters": {
"current": null
}
}
]
}
"""
@db-fixtures
Scenario:
I try to create new category with already exists name.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories
"""
{
"name": "My Content",
"parent": 4
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "User already have category with name \"My Content\".",
"transKey": "createCategoryNameNotUnique",
"type": "error",
"parameters": {
"current": "My Content"
}
}
]
}
"""
@@ -0,0 +1,75 @@
Feature: Delete category
As an authenticated user
I should be able to delete my category
@db-fixtures
Scenario:
I try to delete 'Test' category.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/6
Then I got response with code 204
And it's empty
And database don't has entity CacheBundle:Category
| id | 6 |
@db-fixtures
Scenario:
I try to delete 'Sub main sub 3' category which have subdirectories.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/5
Then I got response with code 204
And it's empty
And database don't has entity CacheBundle:Category
| id | 5 |
And don't has entity CacheBundle:Category
| id | 6 |
@db-fixtures
Scenario:
I try to delete category with unknown id.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to delete category 'My Content' category.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/1
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't delete internal category."
]
}
"""
@db-fixtures
Scenario:
I try to delete category for another user.
Given I authenticated as test@email.com with password test
When I make DELETE request to /api/v1/categories/10
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't delete category owned by other user."
]
}
"""
@@ -0,0 +1,50 @@
Feature: Get category
As an authenticated user
I should be able get information about specified category
@db-fixtures
Scenario:
I try to get 'My Content' category information.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/1
Then I got successful response
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 1)
.field('name', 'My Content')
"""
@db-fixtures
Scenario:
I try to get category information by unknown id.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find Category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to get category owned by other user.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories/9
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't read category owned by other user."
]
}
"""
@@ -0,0 +1,25 @@
Feature: Get list of categories
As an authenticated
I should be able to get list of my categories
@db-fixtures
Scenario:
I try to get list of categories.
Given I authenticated as test@email.com with password test
When I make GET request to /api/v1/categories
Then I got successful response
And it's contains
"""
{
"data": "@array@
.every(entity('CacheBundle:Category', 'category_tree, feed_tree, id'))
.one(field('name', 'My Content'))
.one(field('name', 'Deleted Content'))
",
"count": "@integer@.greaterThan(1)",
"totalCount": "@integer@.greaterThan(1)",
"page": 1,
"limit": "@integer@.greaterThan(1)"
}
"""
+154
View File
@@ -0,0 +1,154 @@
Feature: Move category
As an authenticated user
I should be able to move my category from one place to another
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category to another category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/4
Then I got successful response
And it's contains
"""
{
"data": "@array@
.every(entity('CacheBundle:Category', 'category_tree, feed_tree, id'))
.one(
field('name', 'My Content'),
field('childes',
one(
field('id', 2),
field('childes',
one(
field('id', 4),
field('childes', one(
field('id', 5),
field('childes', one(field('id', 6)))
))
)
)
)
)
)
",
"count": "@integer@.greaterThan(1)",
"totalCount": "@integer@.greaterThan(1)",
"page": 1,
"limit": "@integer@.greaterThan(1)"
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 4 |
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
Scenario:
I try to move unknown category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/1000/move_to/7
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
Scenario:
I try to move my category into unknown.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/1000
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to move 'My Content' category which is internal.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/1/move_to/7
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't move internal category."
]
}
"""
@db-fixtures
Scenario:
I try to move another user category.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/10/move_to/1
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find category with id 10."
]
}
"""
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside it self.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/5
Then I got response with code 400
And it's contains
"""
{
"errors": [
"Try to place category inside itself."
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside one of child.
Given I authenticated as test@email.com with password test
When I make POST request to /api/v1/categories/5/move_to/6
Then I got response with code 400
And it's contains
"""
{
"errors": [
"Try to place category inside it child."
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |
@@ -0,0 +1,274 @@
Feature: Update category
As an authenticated user
I should be able to update any available properties of my category
@db-fixtures
Scenario:
I try to rename 'Test' category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Awesome Category",
"parent": 5
}
"""
Then I got response with code 200
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 6)
.field('name', 'Awesome Category')
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Awesome Category |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Test' category to another category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 4
}
"""
Then I got response with code 200
And it's contains
"""
@object@
.entity('CacheBundle:Category', 'category, feed_tree, id')
.field('id', 6)
.field('name', 'Test')
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 4 |
Scenario:
I try to update 'Test' but not provide necessary information.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value should not be blank.",
"transKey": "updateCategoryNameEmpty",
"type": "error",
"parameters": {
"current": null
}
}
]
}
"""
@db-fixtures
Scenario:
I try to rename category and set already exists name
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "My Content",
"parent": 5
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "User already have category with name \"My Content\".",
"transKey": "updateCategoryNameNotUnique",
"type": "error",
"parameters": {
"current": "My Content"
}
}
]
}
"""
@db-fixtures
Scenario:
I try to update category with unknown id.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/1000
"""
{
"name": "Awesome Category",
"parent": 5
}
"""
Then I got response with code 404
And it's contains
"""
{
"errors": [
"Can't find Category with id 1000."
]
}
"""
@db-fixtures
Scenario:
I try to update 'My Content' category which is internal.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/1
"""
{
"name": "Awesome category"
}
"""
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't update internal category."
]
}
"""
@db-fixtures
Scenario:
I try to update category for another user.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/10
"""
{
"name": "Awesome category",
"parent": 4
}
"""
Then I got response with code 403
And it's contains
"""
{
"errors": [
"Can't update category owned by other user."
]
}
"""
@db-fixtures
Scenario:
I try to move 'Test' category inside it self.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 6
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "Try to place category inside itself.",
"transKey": "updateCategoryParent",
"type": "error",
"parameters": []
}
]
}
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Test' category inside unknown category.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/6
"""
{
"name": "Test",
"parent": 1000
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "This value is not valid.",
"transKey": "updateCategoryParentInvalid",
"type": "error",
"parameters": {
"current": "1000",
"available": null
}
}
]
}
"""
And database has entity CacheBundle:Category
| id | 6 |
| name | Test |
| user | 1 |
| parent | 5 |
@db-fixtures
Scenario:
I try to move 'Sub main sub 3' category inside one of child.
Given I authenticated as test@email.com with password test
When I make PUT request to /api/v1/categories/5
"""
{
"name": "Sub main sub 3",
"parent": 6
}
"""
Then I got response with code 400
And it's contains
"""
{
"errors": [
{
"message": "Try to place category inside it child.",
"transKey": "updateCategoryParent",
"type": "error",
"parameters": []
}
]
}
"""
And database has entity CacheBundle:Category
| id | 5 |
| name | Sub main sub 3 |
| user | 1 |
| parent | 2 |