Example #1
0
 /**
  * Test for `Table::removeFields()`.
  *
  * @since 1.0.0
  * @access public
  *
  * @requires function Freyja\Database\Schema\Table::__construct
  * @requires function Freyja\Database\Schema\Field::__construct
  * @requires function Freyja\Database\Schema\Table::addFields
  */
 public function testRemoveFields()
 {
     // Set accessibility to object property.
     $reflection_type = new ReflectionProperty('Freyja\\Database\\Schema\\Table', 'type');
     $reflection_alter = new ReflectionProperty('Freyja\\Database\\Schema\\Table', 'alter_fields');
     $reflection_type->setAccessible(true);
     $reflection_alter->setAccessible(true);
     $table = new Table('table');
     $f1 = new Field('f1');
     $f2 = new Field('f2');
     $table->removeFields(array($f1, $f2));
     $expected = array('ADD' => array(), 'DROP COLUMN' => array($f1, $f2));
     $this->assertEquals('alter', $reflection_type->getValue($table), 'Failed asserting that Table::addFields() correctly set the query type.');
     $this->assertEquals($expected, $reflection_alter->getValue($table), 'Failed asserting that Table::addFields() correctly set the alter fields.');
 }