Example #1
0
 /**
  * Test for methods: `Fields::char()`, `Field::varchar()`, `Field::text()`,
  * `Field::tinyText()`, `Field::mediumText()`, `Field::longText()`.
  *
  * @since 1.0.0
  * @access public
  *
  * @requires function Freyja\Database\Schema\Field::__construct
  * @requires function Freyja\Database\Schema\Field::char
  * @requires function Freyja\Database\Schema\Field::varchar
  * @requires function Freyja\Database\Schema\Field::text
  * @requires function Freyja\Database\Schema\Field::tinyText
  * @requires function Freyja\Database\Schema\Field::mediumText
  * @requires function Freyja\Database\Schema\Field::longText
  * @requires function ReflectionProperty::setAccessible
  * @requires function ReflectionProperty::getValue
  */
 public function testStringMethods()
 {
     // Set accessibility to object properities.
     $reflection_type = new ReflectionProperty('Freyja\\Database\\Schema\\Field', 'type');
     $reflection_length = new ReflectionProperty('Freyja\\Database\\Schema\\Field', 'length');
     $reflection_type->setAccessible(true);
     $reflection_length->setAccessible(true);
     $field = new Field('name');
     $field->char();
     $char_retrieved_type = $reflection_type->getValue($field);
     $char_retrieved_length = $reflection_length->getValue($field);
     $this->assertEquals('CHAR', $char_retrieved_type, 'Failed asserting that Field::char() correctly set field type.');
     $this->assertEquals(1, $char_retrieved_length, 'Failed asserting that Field::char() correctly set field length.');
     $field = new Field('name');
     $field->varchar(254);
     $varchar_retrieved_type = $reflection_type->getValue($field);
     $varchar_retrieved_length = $reflection_length->getValue($field);
     $this->assertEquals('VARCHAR', $varchar_retrieved_type, 'Failed asserting that Field::varchar() correctly set field type.');
     $this->assertEquals(254, $varchar_retrieved_length, 'Failed asserting that Field::varchar() correctly set field length.');
     $field = new Field('name');
     $field->text();
     $text_retrieved_type = $reflection_type->getValue($field);
     $this->assertEquals('TEXT', $text_retrieved_type, 'Failed asserting that Field::text() correctly set field type.');
     $field = new Field('name');
     $field->tinyText();
     $tinytext_retrieved_type = $reflection_type->getValue($field);
     $this->assertEquals('TINYTEXT', $tinytext_retrieved_type, 'Failed asserting that Field::tinyText() correctly set field type.');
     $field = new Field('name');
     $field->mediumText();
     $mediumtext_retrieved_type = $reflection_type->getValue($field);
     $this->assertEquals('MEDIUMTEXT', $mediumtext_retrieved_type, 'Failed asserting that Field::mediumText() correctly set field type.');
     $field = new Field('name');
     $field->longText();
     $longtext_retrieved_type = $reflection_type->getValue($field);
     $this->assertEquals('LONGTEXT', $longtext_retrieved_type, 'Failed asserting that Field::longText() correctly set field type.');
 }