예제 #1
0
 /**
  * @test
  */
 public function executeReturnsRawObjectDataIfRawQueryResultSettingIsTrue()
 {
     $this->querySettings->expects($this->once())->method('getReturnRawQueryResult')->will($this->returnValue(TRUE));
     $this->persistenceManager->expects($this->once())->method('getObjectDataByQuery')->with($this->query)->will($this->returnValue('rawQueryResult'));
     $expectedResult = 'rawQueryResult';
     $actualResult = $this->query->execute();
     $this->assertEquals($expectedResult, $actualResult);
 }
예제 #2
0
 /**
  * @test
  */
 public function initializeExecutesQueryWithArrayFetchMode()
 {
     $queryResult = $this->getAccessibleMock('Tx_Extbase_Persistence_QueryResult', array('dummy'), array($this->mockQuery));
     $queryResult->injectPersistenceManager($this->mockPersistenceManager);
     $queryResult->injectDataMapper($this->mockDataMapper);
     $this->mockPersistenceManager->expects($this->once())->method('getObjectDataByQuery')->with($this->mockQuery)->will($this->returnValue(array('FAKERESULT')));
     $queryResult->_call('initialize');
 }
예제 #3
0
 /**
  * Replacing a new object which has not yet been persisted by another
  * new object will just replace them in the repository's list of added
  * objects.
  *
  * @test
  * @return void
  */
 public function replaceAddsNewObjectToAddedObjects()
 {
     $existingObject = $this->getMock('Tx_Extbase_DomainObject_DomainObjectInterface');
     $newObject = $this->getMock('Tx_Extbase_DomainObject_DomainObjectInterface');
     $addedObjects = new SplObjectStorage();
     $addedObjects->attach($existingObject);
     $mockBackend = $this->getMock('Tx_Extbase_Persistence_BackendInterface');
     $this->mockPersistenceManager->expects($this->once())->method('getBackend')->will($this->returnValue($mockBackend));
     $mockBackend->expects($this->once())->method('getIdentifierByObject')->with($existingObject)->will($this->returnValue(NULL));
     $mockBackend->expects($this->never())->method('replaceObject');
     $mockSession = $this->getMock('Tx_Extbase_Persistence_Session');
     $this->mockPersistenceManager->expects($this->once())->method('getSession')->will($this->returnValue($mockSession));
     $this->repository->_set('objectType', get_class($newObject));
     $this->repository->_set('addedObjects', $addedObjects);
     $this->repository->replace($existingObject, $newObject);
     $this->assertFalse($addedObjects->contains($existingObject));
     $this->assertTrue($addedObjects->contains($newObject));
 }