FunctionalTest.php 1.25 KB
Newer Older
1
<?php
Sergei Morozov's avatar
Sergei Morozov committed
2

3 4
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;

5
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureFederationsSynchronizer;
6
use function count;
7 8 9

class FunctionalTest extends AbstractTestCase
{
10
    public function testSharding() : void
11 12 13
    {
        $schema = $this->createShopSchema();

14
        $synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm);
15 16 17 18 19
        $synchronizer->dropAllSchema();
        $synchronizer->createSchema($schema);

        $this->sm->selectShard(0);

Sergei Morozov's avatar
Sergei Morozov committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
        $this->conn->insert('Products', [
            'ProductID' => 1,
            'SupplierID' => 2,
            'ProductName' => 'Test',
            'Price' => 10.45,
        ]);

        $this->conn->insert('Customers', [
            'CustomerID' => 1,
            'CompanyName' => 'Foo',
            'FirstName' => 'Benjamin',
            'LastName' => 'E.',
        ]);

        $query = 'SELECT * FROM Products';
        $data  = $this->conn->fetchAll($query);
Gabriel Caruso's avatar
Gabriel Caruso committed
36
        self::assertGreaterThan(0, count($data));
37

Sergei Morozov's avatar
Sergei Morozov committed
38 39
        $query = 'SELECT * FROM Customers';
        $data  = $this->conn->fetchAll($query);
Gabriel Caruso's avatar
Gabriel Caruso committed
40
        self::assertGreaterThan(0, count($data));
41

Sergei Morozov's avatar
Sergei Morozov committed
42
        $data = $this->sm->queryAll('SELECT * FROM Customers');
Gabriel Caruso's avatar
Gabriel Caruso committed
43
        self::assertGreaterThan(0, count($data));
44 45
    }
}