/** * Tests that just accessing the translation will mark the property as dirty, this * is to facilitate the saving process by not having to remember to mark the property * manually * * @return void */ public function testTranslationDirty() { $entity = new TestEntity(); $entity->set('_translations', ['eng' => new Entity(['title' => 'My Title']), 'spa' => new Entity(['title' => 'Titulo'])]); $entity->clean(); $this->assertEquals('My Title', $entity->translation('eng')->get('title')); $this->assertTrue($entity->dirty('_translations')); }
public function testDeleteError() { $this->setExpectedException("RuntimeException", "You can not delete an non persisted Entity"); $entity = new TestEntity(); $entity->set("name", "testname"); $entity->set("key", "key_123456"); $pdoStub = $this->getMock("TestPDO"); $database = new Database($pdoStub); $database->delete($entity); }
public function testAbstractEntity() { $container = DependencyContainer::getInstance(); $container->setConfiguration('./tests/_files/settings_correct.yml'); $container->setRouter('./tests/_files/router_correct.yml'); $container->setTwig(); $container->setDbConnection(); $testEntity = new TestEntity($container->getDbConnection()); $connection = $testEntity->getDb(); $this->assertNotNull($connection); $tableName = $testEntity->getTableName(); $this->assertEquals($tableName, 'test_entity'); }
/** * @dataProvider invalidDataProvider */ public function testHandleRequestWithExistingEntityAndInvalidData($data) { $initialName = 'Initial namn'; $this->entity->setId(1)->setName($initialName); $this->request->setData($data); $this->form->handleRequest($this->request); $this->assertFalse($this->form->isValid()); $this->assertEquals($this->entity->getName(), $initialName); }
public function testFieldsNotMarkedUpdatedIfNothingChanges() { $entity = new TestEntity('hey'); $entity->setName('hey'); $this->assertEquals(0, count($entity->getUpdatedFields())); }
public function testGetId() { $entity = new TestEntity('test-id', 'test-value'); $this->assertEquals('test-id', $entity->getId()); }
public function testCall() { $this->assertEquals('test-value', $this->proxy->getProperty()); }
function testSaveGeneratesAnIDForTheRecord() { $obj = new TestEntity(); $obj->email = '*****@*****.**'; $obj->save(); $this->assertRegExp("/[a-e0-9]+/", $obj->getID()); $this->assertGreaterThan(5, strlen($obj->getID())); }