public function testGetRepository() { $model = new Waf_Model(); $model->register(); $this->entityResolver->setEntityName('Bla'); $this->assertType('Waf_Model_Repository', $this->entityResolver->getRepository()); }
public function testGetModelDefaultsToRegistered() { $property = $this->getMockForAbstractClass('Waf_Model_Mapper_Property_PropertyAbstract', array('Foo', null)); $model = new Waf_Model(); $model->register(); $this->assertSame($model, $property->getModel()); }
public function testMagicCallProxiesToEntityManager() { $entityManager = new Waf_Zend_Controller_Action_Helper_EntityManagerTest_TestEntityManager(); $model = new Waf_Model(); $model->register(); $model->setEntityManager($entityManager); $this->assertEquals('sapperdedosiofoo', $this->entityManagerHelper->test('foo')); }
public function testMagicCallProxiesToRepositoryMethod() { $model = new Waf_Model(); $model->register(); $model->setEntityManager(new Waf_Zend_Controller_Action_Helper_RepositoryTest_TestEntityManager()); $request = new Zend_Controller_Request_Simple(); $request->setControllerName('test'); $request->setModuleName('default'); Zend_Controller_Front::getInstance()->setRequest($request); $this->assertType('Waf_Zend_Controller_Action_Helper_RepositoryTest_TestRepository', $this->repositoryHelper->testMagicCall()); }
public function getModel() { if (null === $this->_model) { $this->setModel(Waf_Model::getRegistered()); } return $this->_model; }
/** * Get Waf_Model_EntityManager from registered Waf_Model instance * * @return Waf_Model_EntityManager */ public function getEntityManager() { if (null === $this->_entityManager) { $this->_entityManager = Waf_Model::getRegistered()->getEntityManager(); } return $this->_entityManager; }
/** * Get the repository to fetch result from * * @return Waf_Model_Repository */ public function getRepository() { if (null === $this->_repository) { $this->_repository = Waf_Model::getRegistered()->getEntityManager()->getRepository($this->getEntityName()); } return $this->_repository; }
public function testGetRepository() { $model = new Waf_Model(); $model->register(); $this->assertType('Waf_Model_Repository', $this->repositoryHelper->repository('test')); }
public function testGetModelGetsRegistered() { $this->resource->getModel(); $this->assertTrue(Waf_Model::isRegistered()); }
/** * Get EntityManager from registered Waf_Model on wakeup * * @return void */ public function __wakeup() { $this->_entityManager = Waf_Model::getRegistered()->getEntityManager(); }
public function testGetBasePathIfSetViaConstructor() { $model = new Waf_Model(array('basepath' => '/bar/app/models')); $this->assertEquals('/bar/app/models', $model->getBasePath()); }