Esempio n. 1
0
 public function testReject()
 {
     $onReject = $this->getMock('\\Repo2\\QueryReactor\\Tests\\Stub');
     $onReject->expects($this->once())->method('__invoke');
     $query = new GenericQuery(Fixtures::getSelect(), null, $onReject);
     $this->assertNull($query->reject(new \Exception()));
 }
 public function testQueriesToTwoShards()
 {
     $sharding = $this->getShardingMock();
     $sharding->expects($this->never())->method('selectGlobal');
     $sharding->expects($this->exactly(2))->method('selectShard')->will($this->returnCallback(function ($distributionName, $distributionValue) {
         return TestUtil::getControllerParams() + ['name' => $distributionName, 'id' => $distributionValue];
     }));
     $queryX = $this->getShardedQueryMock(Fixtures::getSelect());
     $queryX->expects($this->once())->method('getDistributionValue')->will($this->returnValue(1));
     $queryX->expects($this->once())->method('resolve');
     $queryX->expects($this->never())->method('reject');
     $queryY = $this->getShardedQueryMock(Fixtures::getSelect());
     $queryY->expects($this->once())->method('getDistributionValue')->will($this->returnValue(2));
     $queryY->expects($this->once())->method('resolve');
     $queryY->expects($this->never())->method('reject');
     $queries = new \ArrayObject([$queryX, $queryY]);
     $reactor = $this->createReactor($this->createShardingController($sharding));
     $reactor->execIterator($queries->getIterator())->await();
 }
Esempio n. 3
0
 public function testSelectWithIteratorCascading()
 {
     $expression = Fixtures::getSelect();
     $cascadedQueryY = $this->getQueryMock($expression);
     $cascadedQueryY->expects($this->once())->method('resolve');
     $cascadedQueryZ = $this->getQueryMock($expression);
     $cascadedQueryZ->expects($this->once())->method('resolve');
     $cascading = new \ArrayObject([$cascadedQueryY, $cascadedQueryZ]);
     $query = $this->getQueryMock($expression);
     $query->expects($this->once())->method('resolve')->will($this->returnValue($cascading->getIterator()));
     $this->queryAwait($query);
 }