Example #1
0
    /**
     * buildSetterBoolContent
     * @param Field  $field
     * @param string $content
     * @return string
     */
    protected function buildSetterBoolContent(Field $field, $content)
    {
        $content .= '		$preFilterValue = $' . $field->getShortName() . ';
        if(!is_null($preFilterValue)) {
            $' . $field->getShortName() . ' = $this->getFilter()->sanitize($' . $field->getShortName() . ', \'boolean\');
            if(is_null($' . $field->getShortName() . ')) {
                throw new \\InvalidArgumentException(\'Expected Type of boolean (1, true, on, yes, 0, false, off, no, ""), Invalid Value: \'.$preFilterValue);
            }
        } else {
            $' . $field->getShortName() . ' = $preFilterValue;
        }
';
        return $content;
    }
Example #2
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;
 }