예제 #1
0
 /**
  * @todo   Implement testAddColumnOptions().
  */
 public function testAddColumnOptions()
 {
     try {
         $this->object->addColumnOptions('int', array('default' => 'sp_call()'));
         $this->fail('addColumnOptions does not accept function ' . 'calls as "default" option!');
     } catch (Exception $e) {
         $msg = 'MySQL does not support function calls ' . 'as default values, constants only.';
         $this->assertEquals($msg, $e->getMessage());
     }
     $colOpts = $this->object->addColumnOptions('int', '');
     $this->assertInternalType('string', $colOpts);
     $this->assertEmpty($colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('unsigned' => true));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' UNSIGNED NULL DEFAULT NULL', $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('auto_increment' => true));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' auto_increment NOT NULL', $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('null' => false));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' NOT NULL', $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('after' => 'name'));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' NULL DEFAULT NULL AFTER `name`', $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('default' => 1));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' NOT NULL DEFAULT 1', $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('default' => true));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(" NOT NULL DEFAULT '1'", $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('default' => 'string'));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(" NOT NULL DEFAULT 'string'", $colOpts);
     $colOpts = $this->object->addColumnOptions('int', array('unsigned' => true, 'auto_increment' => true, 'null' => false, 'after' => 'name', 'default' => 1));
     $this->assertInternalType('string', $colOpts);
     $this->assertEquals(' UNSIGNED auto_increment NOT NULL DEFAULT 1 AFTER `name`', $colOpts);
 }