3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\Tests\DBAL\Schema\Synchronizer;
22 use Doctrine\DBAL\DriverManager;
23 use Doctrine\DBAL\Schema\Schema;
24 use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
26 class SingleDatabaseSynchronizerTest extends \PHPUnit_Framework_TestCase
29 private $synchronizer;
31 public function setUp()
33 $this->conn = DriverManager::getConnection(array(
34 'driver' => 'pdo_sqlite',
37 $this->synchronizer = new SingleDatabaseSynchronizer($this->conn);
40 public function testGetCreateSchema()
42 $schema = new Schema();
43 $table = $schema->createTable('test');
44 $table->addColumn('id', 'integer');
45 $table->setPrimaryKey(array('id'));
47 $sql = $this->synchronizer->getCreateSchema($schema);
48 $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
51 public function testGetUpdateSchema()
53 $schema = new Schema();
54 $table = $schema->createTable('test');
55 $table->addColumn('id', 'integer');
56 $table->setPrimaryKey(array('id'));
58 $sql = $this->synchronizer->getUpdateSchema($schema);
59 $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
62 public function testGetDropSchema()
64 $schema = new Schema();
65 $table = $schema->createTable('test');
66 $table->addColumn('id', 'integer');
67 $table->setPrimaryKey(array('id'));
69 $this->synchronizer->createSchema($schema);
71 $sql = $this->synchronizer->getDropSchema($schema);
72 $this->assertEquals(array('DROP TABLE test'), $sql);
75 public function testGetDropAllSchema()
77 $schema = new Schema();
78 $table = $schema->createTable('test');
79 $table->addColumn('id', 'integer');
80 $table->setPrimaryKey(array('id'));
82 $this->synchronizer->createSchema($schema);
84 $sql = $this->synchronizer->getDropAllSchema();
85 $this->assertEquals(array('DROP TABLE test'), $sql);