Example #1
0
 function it_can_return_column_by_name(Column $column1, Column $column2, Column $column3)
 {
     $column1->getName()->willReturn('id');
     $column2->getName()->willReturn('firstName');
     $column3->getName()->willReturn('lastName');
     $this->addColumn($column1);
     $this->addColumn($column2);
     $this->addColumn($column3);
     $this->getColumn('lastName')->beAnInstanceOf('Brzoski\\Elements\\Column');
     $this->getColumn('lastName')->getName()->shouldBe('lastName');
 }
Example #2
0
 public static function export(\PDO $database, $databaseName)
 {
     try {
         $stmt = $database->query('SHOW TABLES');
         $db = new Database($databaseName);
         foreach ($stmt as $k => $v) {
             $table = new Table();
             $table->setName($v[0]);
             $query = $database->query('SHOW COLUMNS FROM ' . $table->getName());
             $columns = $query->fetchAll(\PDO::FETCH_ASSOC);
             foreach ($columns as $c) {
                 $column = new Column();
                 $column->setName($c['Field']);
                 $column->setDefault($c['Default']);
                 $column->setExtra($c['Extra']);
                 $column->setKey($c['Key']);
                 $column->setNull($c['Null']);
                 $column->setType($c['Type']);
                 $table->addColumn($column);
             }
             $db->addTable($table);
         }
         $stmt->closeCursor();
     } catch (\PDOException $e) {
         echo "Error: " . $e->getMessage();
         exit;
     }
     return $db;
 }
Example #3
0
 function it_return_query(Column $column, Table $table)
 {
     $table->getName()->willReturn('dbdiff');
     $column->getQueryString()->willReturn('id int(10) unsigned NOT NULL PRIMARY KEY auto_increment');
     $this::query($column, $table)->shouldBe('ALTER TABLE dbdiff MODIFY id int(10) unsigned NOT NULL PRIMARY KEY auto_increment');
 }
Example #4
0
 function it_return_error_message(Column $column, Table $table)
 {
     $column->getName()->willReturn('users');
     $this->beConstructedWith($column, $table);
     $this->shouldHaveType('Brzoski\\Differences\\ColumnNotExists');
 }