_rsm = new ResultSetMapping; $this->_em = $this->_getTestEntityManager(); } /** * For SQL: SELECT id, status, username, name FROM cms_users */ public function testBasicResultSetMapping() { $this->_rsm->addEntityResult( $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), 'u' ); $this->_rsm->addFieldResult('u', 'id', 'id'); $this->_rsm->addFieldResult('u', 'status', 'status'); $this->_rsm->addFieldResult('u', 'username', 'username'); $this->_rsm->addFieldResult('u', 'name', 'name'); $this->assertFalse($this->_rsm->isScalarResult('id')); $this->assertFalse($this->_rsm->isScalarResult('status')); $this->assertFalse($this->_rsm->isScalarResult('username')); $this->assertFalse($this->_rsm->isScalarResult('name')); $this->assertTrue($this->_rsm->getClass('u') instanceof ClassMetadata); $class = $this->_rsm->getOwningClass('id'); $this->assertTrue($class instanceof ClassMetadata); $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $class->name); $this->assertEquals('u', $this->_rsm->getEntityAlias('id')); $this->assertEquals('u', $this->_rsm->getEntityAlias('status')); $this->assertEquals('u', $this->_rsm->getEntityAlias('username')); $this->assertEquals('u', $this->_rsm->getEntityAlias('name')); $this->assertEquals('id', $this->_rsm->getFieldName('id')); $this->assertEquals('status', $this->_rsm->getFieldName('status')); $this->assertEquals('username', $this->_rsm->getFieldName('username')); $this->assertEquals('name', $this->_rsm->getFieldName('name')); } }