Repo2\QueryReactor\Tests\Sharding\ShardingControllerTest::testQueriesToTwoShards PHP Метод

testQueriesToTwoShards() публичный Метод

    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();
    }