FunctionalTest.php 1.23 KB
Newer Older
1 2 3
<?php
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;

4
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureFederationsSynchronizer;
5 6 7 8 9 10 11

class FunctionalTest extends AbstractTestCase
{
    public function testSharding()
    {
        $schema = $this->createShopSchema();

12
        $synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm);
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
        $synchronizer->dropAllSchema();
        $synchronizer->createSchema($schema);

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

        $this->conn->insert("Products", array(
            "ProductID" => 1,
            "SupplierID" => 2,
            "ProductName" => "Test",
            "Price" => 10.45
        ));

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

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

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

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