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.

40 lines
1.2 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:gt"]
  19. */
  20. public function test_collection_store_unprocessable($field)
  21. {
  22. $this->modelWithPolicy('collections', ['permission:collections.store'])
  23. ->loginAsAdmin()
  24. ->postJson(route("api.collections.store"), $collection = $this->make(collection::class, smash: $field, withDependency: true))
  25. ->assertUnprocessable();
  26. }
  27. public function test_collection_store_forbidden()
  28. {
  29. $this->modelWithPolicy('collections', ['permission:collections.store'])
  30. ->loginAs(['wrong.permission'])
  31. ->postJson(route("api.collections.store"), [])
  32. ->assertForbidden();
  33. }
  34. }