Skip to content

Commit

Permalink
change inheritance HtmlProperty from StringProperty to TextProperty t…
Browse files Browse the repository at this point in the history
…o allow SQL type LONGTEXT. Set HtmlProperty type LONGTEXT by default.
  • Loading branch information
veve40 committed Mar 17, 2020
1 parent e762f86 commit 2f148aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/Charcoal/Property/HtmlProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
namespace Charcoal\Property;

// From 'charcoal-property'
use Charcoal\Property\StringProperty;
use Charcoal\Property\TextProperty;

/**
* HTML Property.
*
* The html property is a specialized string property.
*/
class HtmlProperty extends StringProperty
class HtmlProperty extends TextProperty
{
const DEFAULT_LONG = true;

/**
* @var boolean
*/
protected $long = self::DEFAULT_LONG;

/**
* The available filesystems (used in TinyMCE's elFinder media manager).
*
Expand Down Expand Up @@ -67,14 +74,4 @@ public function getAllowHtml()
{
return true;
}

/**
* Get the SQL type (Storage format).
*
* @return string The SQL type
*/
public function sqlType()
{
return 'TEXT';
}
}
2 changes: 1 addition & 1 deletion src/Charcoal/Property/TextProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextProperty extends StringProperty
/**
* @var boolean
*/
private $long = self::DEFAULT_LONG;
protected $long = self::DEFAULT_LONG;

/**
* @return string
Expand Down
5 changes: 5 additions & 0 deletions tests/Charcoal/Property/HtmlPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function testDefaults()
$this->assertTrue($this->obj['allowNull']);
$this->assertTrue($this->obj['allowHtml']);
$this->assertTrue($this->obj['active']);
$this->assertTrue($this->obj['long']);
}

/**
Expand All @@ -66,7 +67,11 @@ public function testDefaultMaxLength()
*/
public function testSqlType()
{
$this->obj->setLong(false);
$this->assertEquals('TEXT', $this->obj->sqlType());

$this->obj->setLong(true);
$this->assertEquals('LONGTEXT', $this->obj->sqlType());
}

public function testFilesystem()
Expand Down

0 comments on commit 2f148aa

Please sign in to comment.