Example #1
0
 /**
  * To be used when testing constructor
  *
  * @return Field
  */
 private function constructorStuff($type, $key = "PRI", $extra = "auto_increment", $null = "YES", $comment = "comment")
 {
     //ARRANGE
     $field = "Field";
     $mockStdClass = $this->getMockStdClass();
     $mockStdClass->Field = $field;
     $mockStdClass->Key = $key;
     $mockStdClass->Extra = $extra;
     $mockStdClass->Type = $type;
     $mockStdClass->Null = $null;
     $otherMockStdClass = $this->getMockStdClass();
     $otherMockStdClass->COLUMN_COMMENT = $comment;
     $table = "tableName";
     //ACT
     $result = new Field($mockStdClass, $table, $otherMockStdClass);
     //ASSERT
     $this->assertEquals($field, $result->getName());
     if ($key == "PRI") {
         $this->assertTrue($result->isPrimary());
     } else {
         $this->assertFalse($result->isPrimary());
     }
     if ($extra == "auto_increment") {
         $this->assertTrue($result->isAutoIncrementing());
     } else {
         $this->assertFalse($result->isAutoIncrementing());
     }
     if ($null == "YES") {
         $this->assertTrue($result->isNullable());
     } else {
         $this->assertFalse($result->isNullable());
     }
     if ($comment == "") {
         $this->assertEquals(ucfirst($field), $result->getDescription());
     } else {
         $this->assertEquals($comment, $result->getDescription());
     }
     $this->assertEquals($field, $result->getName());
     return $result;
 }