[+BUGFIX] (Persistence) clone setDefaultQuerySettings for new queries
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / RepositoryTest.php
index d26f509..efd9382 100644 (file)
@@ -191,6 +191,25 @@ class Tx_Extbase_Tests_Unit_Persistence_RepositoryTest extends Tx_Extbase_Tests_
                $this->repository->createQuery();
        }
 
+       /**
+        * @test
+        */
+       public function createQueryReturnsQueryWithUnmodifiedDefaultQuerySettings() {
+               $mockQueryFactory = $this->getMock('Tx_Extbase_Persistence_QueryFactory');
+               $mockQuery = new Tx_Extbase_Persistence_Query('foo');
+
+               $mockDefaultQuerySettings = $this->getMock('Tx_Extbase_Persistence_QuerySettingsInterface');
+               $this->repository->injectQueryFactory($mockQueryFactory);
+               $this->repository->setDefaultQuerySettings($mockDefaultQuerySettings);
+
+               $mockQueryFactory->expects($this->once())->method('create')->will($this->returnValue($mockQuery));
+               $this->repository->createQuery();
+
+               $instanceQuerySettings = $mockQuery->getQuerySettings();
+               $this->assertEquals($mockDefaultQuerySettings, $instanceQuerySettings);
+               $this->assertNotSame($mockDefaultQuerySettings, $instanceQuerySettings);
+       }
+
        /**
         * @test
         */