/** * Tests `::toArray()` method. */ public function testToArray() { $dataMapper = new ArraySerializer(); $hobbit = new Fixtures\Hobbit(); $hobbit->setId(1); $hobbit->setName('Frodo'); $hobbit->setHeight(140); $hobbit->setSurname('Baggins'); $this->assertEquals(['id' => 1, 'name' => 'Frodo', 'height' => 140, 'surname' => 'Baggins'], $dataMapper->toArray($hobbit)); }
/** * Tests updating an object with data. */ public function testUpdateWithData() { $mocks = $this->provideMocks(); $repository = $this->provideRepository($mocks); $hobbit = new Fixtures\Hobbit(); $hobbit->setId(2); $hobbit->setName('Bilbo'); $hobbit->setSurname('Baggins'); $hobbit->setHeight(130); $repository->updateWithData($hobbit, ['name' => 'Frodo', 'height' => 140]); $this->assertEquals(2, $hobbit->getId()); $this->assertEquals('Frodo', $hobbit->getName()); $this->assertEquals('Baggins', $hobbit->getSurname()); $this->assertEquals(140, $hobbit->getHeight()); }