DeleteOperationTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Tests\Unit\Service\Rest\Operation;
  3. use App\Service\Rest\Operation\DeleteOperation;
  4. use PHPUnit\Framework\TestCase;
  5. class TestableDeleteOperation extends DeleteOperation {
  6. public function getExpectedResult(): ?array { return parent::getExpectedResult(); }
  7. }
  8. class DeleteOperationTest extends TestCase
  9. {
  10. /**
  11. * @see DeleteOperation::__construct()
  12. * @see DeleteOperation::getMethod()
  13. * @see DeleteOperation::getEntityName()
  14. * @see DeleteOperation::getPath()
  15. * @see DeleteOperation::__toString()
  16. */
  17. public function testGetters(): void
  18. {
  19. $operation = new DeleteOperation(
  20. 'Delete a dinosaur',
  21. 'dinosaur',
  22. 1
  23. );
  24. $this->assertEquals('DELETE', $operation->getMethod());
  25. $this->assertEquals('dinosaur', $operation->getEntityName());
  26. $this->assertEquals('dinosaur/1', $operation->getPath());
  27. $this->assertEquals('DELETE dinosaur/1', (string)$operation);
  28. }
  29. /**
  30. * @see DeleteOperation::getExpectedResult()
  31. */
  32. public function testGetExpectedResult(): void {
  33. $operation = new TestableDeleteOperation(
  34. 'Delete a dinosaur',
  35. 'dinosaur',
  36. 1
  37. );
  38. $this->assertEquals(null, $operation->getExpectedResult());
  39. }
  40. /**
  41. * @see DeleteOperation::getChangeLog()
  42. */
  43. public function testGetChangeLog(): void
  44. {
  45. $operation = new DeleteOperation(
  46. 'Delete a dinosaur',
  47. 'dinosaur',
  48. 1
  49. );
  50. $this->assertEquals(
  51. ['[DELETE dinosaur/1]'],
  52. $operation->getChangeLog()
  53. );
  54. }
  55. }