UpdateOperationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use App\Service\Rest\Operation\CreateOperation;
  3. use App\Service\Rest\Operation\UpdateOperation;
  4. use PHPUnit\Framework\TestCase;
  5. class UpdateOperationTest extends TestCase
  6. {
  7. public function testGetters() {
  8. $operation = new UpdateOperation(
  9. 'Update a dinosaur',
  10. 'dinosaur',
  11. 1,
  12. ['weight' => 1800],
  13. ['weight' => 1600]
  14. );
  15. $this->assertEquals('PUT', $operation->getMethod());
  16. $this->assertEquals('dinosaur', $operation->getEntity());
  17. $this->assertEquals('dinosaur/1', $operation->getPath());
  18. $this->assertEquals(['weight' => 1600], $operation->getInitialData());
  19. $this->assertEquals(['weight' => 1800], $operation->getData());
  20. $this->assertEquals('PUT dinosaur/1', (string)$operation);
  21. }
  22. public function testGetChangeLog() {
  23. $operation = new UpdateOperation(
  24. 'Update a dinosaur',
  25. 'dinosaur',
  26. 1,
  27. ['weight' => 1800, 'attrs' => ['vision' => 'movement-based', 'teeth' => '99']],
  28. ['weight' => 1600, 'attrs' => ['vision' => 'movement-based', 'teeth' => '100']]
  29. );
  30. $this->assertEquals(
  31. [
  32. '[PUT dinosaur/1]',
  33. 'weight : `1600` => `1800`',
  34. 'attrs.teeth : `100` => `99`',
  35. ],
  36. $operation->getChangeLog()
  37. );
  38. }
  39. }