/** * @param array $fieldsChanges * @param mixed $expected * @param bool $doRemove * * @dataProvider getChangesDataProvider */ public function testGetChanges($fieldsChanges, $expected, $doRemove) { if ($fieldsChanges) { $this->repo->expects($this->any())->method('findOneBy')->with($this->isType('array'))->will($this->returnValue($fieldsChanges)); } else { $newFieldsChanges = new FieldsChanges([]); $newFieldsChanges->setEntityClass(self::CLASS_NAME)->setEntityId(1); $this->doctrineHelper->expects($this->once())->method('createEntityInstance')->will($this->returnValue($newFieldsChanges)); $this->em->expects($this->once())->method('persist')->with($this->equalTo($newFieldsChanges)); } if ($doRemove) { $this->em->expects($this->once())->method('remove')->with($this->equalTo($fieldsChanges)); } $this->assertEquals($expected, $this->manager->getChanges(new \stdClass(), $doRemove)); }
/** * @param array $fields * * @dataProvider constructDataProvider */ public function testConstruct(array $fields) { $fieldsChanges = new FieldsChanges($fields); $this->assertEquals($fields, $fieldsChanges->getChangedFields()); }