You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

  1. <?php
  2. namespace Tests\Feature\Collection;
  3. use App\Models\Collection;
  4. use App\Documents\UserDocument;
  5. use Tests\Bootstrap;
  6. use Illuminate\Support\Arr;
  7. class CollectionStoreTest extends Bootstrap
  8. {
  9. public function test_collection_store_success()
  10. {
  11. $this->modelWithPolicy('collections', ['permission:collections.store'])
  12. ->loginAs(['collections.store'])
  13. ->postJson(route('api.collections.store'), $collection = $this->make(Collection::class))
  14. ->assertCreated();
  15. }
  16. /**
  17. * @testWith
  18. * ["name:gtString"]
  19. * ["name:numeric"]
  20. * ["name:null"]
  21. * ["path:gtString"]
  22. * ["path:numeric"]
  23. * ["public:string"]
  24. * ["disk:numeric"]
  25. * ["disk:null"]
  26. * ["disk:gtString"]
  27. * ["count:null"]
  28. * ["count:string"]
  29. * ["count:gt:100000"]
  30. *
  31. */
  32. public function test_collection_store_unprocessable($field)
  33. {
  34. $this->modelWithPolicy('collections', ['permission:collections.store'])
  35. ->loginAsAdmin()
  36. ->postJson(route("api.collections.store"), $collection = $this->make(collection::class, smash: $field, withDependency: true))
  37. ->assertUnprocessable();
  38. }
  39. public function test_collection_store_forbidden()
  40. {
  41. $this->modelWithPolicy('collections', ['permission:collections.store'])
  42. ->loginAs(['wrong.permission'])
  43. ->postJson(route("api.collections.store"), [])
  44. ->assertForbidden();
  45. }
  46. }