| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Tests\Service\Rest\Operation;
- use App\Service\Rest\Operation\UpdateOperation;
- use PHPUnit\Framework\TestCase;
- class UpdateOperationTest extends TestCase
- {
- /**
- * @see UpdateOperation::__construct()
- * @see UpdateOperation::getMethod()
- * @see UpdateOperation::getEntityName()
- * @see UpdateOperation::getPath()
- * @see UpdateOperation::getInitialData()
- * @see UpdateOperation::getData()
- * @see UpdateOperation::__toString()
- */
- public function testGetters(): void
- {
- $operation = new UpdateOperation(
- 'Update a dinosaur',
- 'dinosaur',
- 1,
- ['weight' => 1800],
- ['weight' => 1600]
- );
- $this->assertEquals('PUT', $operation->getMethod());
- $this->assertEquals('dinosaur', $operation->getEntityName());
- $this->assertEquals('dinosaur/1', $operation->getPath());
- $this->assertEquals(['weight' => 1600], $operation->getInitialData());
- $this->assertEquals(['weight' => 1800], $operation->getData());
- $this->assertEquals('PUT dinosaur/1', (string)$operation);
- }
- /**
- * @see UpdateOperation::getChangeLog()
- */
- public function testGetChangeLog(): void
- {
- $operation = new UpdateOperation(
- 'Update a dinosaur',
- 'dinosaur',
- 1,
- ['weight' => 1800, 'attrs' => ['vision' => 'movement-based', 'teeth' => '99', 'adn' => ['1' => 'b'], 'color' => 'green']],
- ['weight' => 1600, 'attrs' => ['vision' => 'movement-based', 'teeth' => '100', 'adn' => ['1' => 'a']]]
- );
- $this->assertEquals(
- [
- '[PUT dinosaur/1]',
- 'weight : `1600` => `1800`',
- 'attrs.teeth : `100` => `99`',
- 'attrs.adn.1 : `a` => `b`',
- 'attrs.color : (new) => `green`',
- ],
- $operation->getChangeLog()
- );
- }
- }
|