UpdateOperationTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ['id' => 1, 'weight' => 1600],
  12. ['weight' => 1800]
  13. );
  14. $this->assertEquals('PUT', $operation->getMethod());
  15. $this->assertEquals('dinosaur', $operation->getEntity());
  16. $this->assertEquals('dinosaur/1', $operation->getPath());
  17. $this->assertEquals(['id' => 1, 'weight' => 1600], $operation->getCurrentData());
  18. $this->assertEquals(['weight' => 1800], $operation->getData());
  19. $this->assertEquals('PUT dinosaur/1', (string)$operation);
  20. }
  21. public function testGetChangeLog() {
  22. $operation = new UpdateOperation(
  23. 'Update a dinosaur',
  24. 'dinosaur',
  25. ['id' => 1, 'weight' => 1600, 'attrs' => ['vision' => 'movement-based', 'teeth' => '100']],
  26. ['weight' => 1800, 'attrs' => ['vision' => 'movement-based', 'teeth' => '99']]
  27. );
  28. $this->assertEquals(
  29. [
  30. '[PUT dinosaur/1]',
  31. 'weight : `1600` => `1800`',
  32. 'attrs.teeth : `100` => `99`',
  33. ],
  34. $operation->getChangeLog()
  35. );
  36. }
  37. }