| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- use App\Service\Rest\Operation\CreateOperation;
- use App\Service\Rest\Operation\UpdateOperation;
- use PHPUnit\Framework\TestCase;
- class UpdateOperationTest extends TestCase
- {
- public function testGetters() {
- $operation = new UpdateOperation(
- 'Update a dinosaur',
- 'dinosaur',
- ['id' => 1, 'weight' => 1600],
- ['weight' => 1800]
- );
- $this->assertEquals('PUT', $operation->getMethod());
- $this->assertEquals('dinosaur', $operation->getEntity());
- $this->assertEquals('dinosaur/1', $operation->getPath());
- $this->assertEquals(['id' => 1, 'weight' => 1600], $operation->getCurrentData());
- $this->assertEquals(['weight' => 1800], $operation->getData());
- $this->assertEquals('PUT dinosaur/1', (string)$operation);
- }
- public function testGetChangeLog() {
- $operation = new UpdateOperation(
- 'Update a dinosaur',
- 'dinosaur',
- ['id' => 1, 'weight' => 1600, 'attrs' => ['vision' => 'movement-based', 'teeth' => '100']],
- ['weight' => 1800, 'attrs' => ['vision' => 'movement-based', 'teeth' => '99']]
- );
- $this->assertEquals(
- [
- '[PUT dinosaur/1]',
- 'weight : `1600` => `1800`',
- 'attrs.teeth : `100` => `99`',
- ],
- $operation->getChangeLog()
- );
- }
- }
|