Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Schema / Synchronizer / SingleDatabaseSynchronizerTest.php
1 <?php
2 /*
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.
14  *
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>.
18  */
19
20 namespace Doctrine\Tests\DBAL\Schema\Synchronizer;
21
22 use Doctrine\DBAL\DriverManager;
23 use Doctrine\DBAL\Schema\Schema;
24 use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
25
26 class SingleDatabaseSynchronizerTest extends \PHPUnit_Framework_TestCase
27 {
28     private $conn;
29     private $synchronizer;
30
31     public function setUp()
32     {
33         $this->conn = DriverManager::getConnection(array(
34             'driver' => 'pdo_sqlite',
35             'memory' => true,
36         ));
37         $this->synchronizer = new SingleDatabaseSynchronizer($this->conn);
38     }
39
40     public function testGetCreateSchema()
41     {
42         $schema = new Schema();
43         $table = $schema->createTable('test');
44         $table->addColumn('id', 'integer');
45         $table->setPrimaryKey(array('id'));
46
47         $sql = $this->synchronizer->getCreateSchema($schema);
48         $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
49     }
50
51     public function testGetUpdateSchema()
52     {
53         $schema = new Schema();
54         $table = $schema->createTable('test');
55         $table->addColumn('id', 'integer');
56         $table->setPrimaryKey(array('id'));
57
58         $sql = $this->synchronizer->getUpdateSchema($schema);
59         $this->assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
60     }
61
62     public function testGetDropSchema()
63     {
64         $schema = new Schema();
65         $table = $schema->createTable('test');
66         $table->addColumn('id', 'integer');
67         $table->setPrimaryKey(array('id'));
68
69         $this->synchronizer->createSchema($schema);
70
71         $sql = $this->synchronizer->getDropSchema($schema);
72         $this->assertEquals(array('DROP TABLE test'), $sql);
73     }
74
75     public function testGetDropAllSchema()
76     {
77         $schema = new Schema();
78         $table = $schema->createTable('test');
79         $table->addColumn('id', 'integer');
80         $table->setPrimaryKey(array('id'));
81
82         $this->synchronizer->createSchema($schema);
83
84         $sql = $this->synchronizer->getDropAllSchema();
85         $this->assertEquals(array('DROP TABLE test'), $sql);
86     }
87 }
88