/** * Test for methods: `Field::integer()`, `Field::tinyInteger()`, * `Field::smallInteger()`, `Field::mediumInteger()`, `Field::bigInteger()`. * * @since 1.0.0 * @access public * * @requires function Freyja\Database\Schema\Field::__construct * @requires function Freyja\Database\Schema\Field::integer * @requires function Freyja\Database\Schema\Field::tinyInteger * @requires function Freyja\Database\Schema\Field::smallInteger * @requires function Freyja\Database\Schema\Field::mediumInteger * @requires function Freyja\Database\Schema\Field::bigInteger * @requires function ReflectionProperty::setAccessible * @requires function ReflectionProperty::getValue */ public function testIntegerMethods() { // Set accessibility to object properties. $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->integer(); $integer_retrieved_type = $reflection_type->getValue($field); $integer_retrieved_length = $reflection_length->getValue($field); $this->assertEquals('INT', $integer_retrieved_type, 'Failed asserting that Field::integer() correctly set the field type.'); $this->assertEquals(11, $integer_retrieved_length, 'Failed asserting that Field::integer() correctly set the field length.'); $field = new Field('name'); $field->tinyInteger(4); $tiny_retrieved_type = $reflection_type->getValue($field); $tiny_retrieved_length = $reflection_length->getValue($field); $this->assertEquals('TINYINT', $tiny_retrieved_type, 'Failed asserting that Field::tinyInteger() correctly set the field type.'); $this->assertEquals(4, $tiny_retrieved_length, 'Failed asserting that Field::tinyInteger() correctly set the field length.'); $field = new Field('name'); $field->smallInteger('4'); $small_retrieved_type = $reflection_type->getValue($field); $small_retrieved_length = $reflection_length->getValue($field); $this->assertEquals('SMALLINT', $small_retrieved_type, 'Failed asserting that Field::smallInteger() correctly set the field type.'); $this->assertEquals(4, $small_retrieved_length, 'Failed asserting that Field::smallInteger() correctly set the field length.'); $field = new Field('name'); $field->mediumInteger(11); $medium_retrieved_type = $reflection_type->getValue($field); $medium_retrieved_length = $reflection_length->getValue($field); $this->assertEquals('MEDIUMINT', $medium_retrieved_type, 'Failed asserting that Field::mediumInteger() correctly set the field type.'); $this->assertEquals(9, $medium_retrieved_length, 'Failed asserting that Field::mediumInteger() correctly set the field length.'); $field = new Field('name'); $field->bigInteger(18); $big_retrieved_type = $reflection_type->getValue($field); $big_retrieved_length = $reflection_length->getValue($field); $this->assertEquals('BIGINT', $big_retrieved_type, 'Failed asserting that Field::bigInteger() correctly set the field type.'); $this->assertEquals(18, $big_retrieved_length, 'Failed asserting that Field::bigInteger() correctly set the field length.'); }