DeleteOperationTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. {
  7. public function getExpectedResult(): ?array
  8. {
  9. return parent::getExpectedResult();
  10. }
  11. }
  12. class DeleteOperationTest extends TestCase
  13. {
  14. /**
  15. * @see DeleteOperation::__construct()
  16. * @see DeleteOperation::getMethod()
  17. * @see DeleteOperation::getEntityName()
  18. * @see DeleteOperation::getPath()
  19. * @see DeleteOperation::__toString()
  20. */
  21. public function testGetters(): void
  22. {
  23. $operation = new DeleteOperation(
  24. 'Delete a dinosaur',
  25. 'dinosaur',
  26. 1
  27. );
  28. $this->assertEquals('DELETE', $operation->getMethod());
  29. $this->assertEquals('dinosaur', $operation->getEntityName());
  30. $this->assertEquals('dinosaur/1', $operation->getPath());
  31. $this->assertEquals('DELETE dinosaur/1', (string) $operation);
  32. }
  33. /**
  34. * @see DeleteOperation::getExpectedResult()
  35. */
  36. public function testGetExpectedResult(): void
  37. {
  38. $operation = new TestableDeleteOperation(
  39. 'Delete a dinosaur',
  40. 'dinosaur',
  41. 1
  42. );
  43. $this->assertEquals(null, $operation->getExpectedResult());
  44. }
  45. /**
  46. * @see DeleteOperation::getChangeLog()
  47. */
  48. public function testGetChangeLog(): void
  49. {
  50. $operation = new DeleteOperation(
  51. 'Delete a dinosaur',
  52. 'dinosaur',
  53. 1
  54. );
  55. $this->assertEquals(
  56. ['[DELETE dinosaur/1]'],
  57. $operation->getChangeLog()
  58. );
  59. }
  60. }