diff -u b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php --- b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php +++ b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php @@ -157,47 +157,32 @@ /** * {@inheritdoc} */ - public function getCache() { - return $this->cache; + public function isCacheable() { + return $this->cache > 0; } /** * {@inheritdoc} */ - public function getFilterBag() { - return $this->filterBag; + public function setWeight($weight) { + $this->set('weight', $weight); + return $this; } /** * {@inheritdoc} */ - public function setWeight($newWeight) { - $weight = $newWeight; - return this; + public function setRoles($roles) { + $this->set('roles', $roles); + return $this; } /** * {@inheritdoc} */ - public function setRoles($newRoles) { - $roles = $newRoles; - return this; - } - - /** - * {@inheritdoc} - */ - public function setCache($newCache) { - $cache = $newCache; - return this; - } - - /** - * {@inheritdoc} - */ - public function setFilterBag($newFilterBag) { - $filterBag = $newFilterBag; - return this; + public function setCache($cache) { + $this->set('cache', $cache); + return $this; } /** diff -u b/core/modules/filter/lib/Drupal/filter/FilterFormatInterface.php b/core/modules/filter/lib/Drupal/filter/FilterFormatInterface.php --- b/core/modules/filter/lib/Drupal/filter/FilterFormatInterface.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatInterface.php @@ -57,6 +57,7 @@ * malformed or is the fallback format (which is available to all users). */ public function getPermissionName(); + /** * Returns the weight of the format in the text format selector. * @@ -75,62 +76,43 @@ /** - * Returns the cache value (whether processed text of this format can be cached). + * Returns the cache status. * * @return bool - * The cache value - */ - public function getCache(); - - /** - * Returns the format's FilterBag (holds the collection of filters that are attached to this format). - * - * @return \Drupal\filter\FilterBag - * The form + * TRUE if the filter is cached. */ - public function getFilterBag(); + public function isCacheable(); /** * Sets the weight to the given value. * - * @param int $newWeight + * @param int $weight * The desired weight. * * @return \Drupal\filter\FilterFormatInterface * The class instance this method is called on. */ - public function setWeight($newWeight); + public function setWeight($weight); /** * Sets the list of user role IDs to the given array. * - * @param array $newRoles + * @param array $roles * The desired user role ID array. * * @return \Drupal\filter\FilterFormatInterface * The class instance this method is called on. */ - public function setRoles($newRoles); + public function setRoles($roles); /** * Sets the cache value (whether or not text of this format can be cached). * - * @param bool $newCache + * @param bool $cache * The desired cache value. * * @return \Drupal\filter\FilterFormatInterface * The class instance this method is called on. */ - public function setCache($newCache); - - /** - * Sets the format's FilterBag to the given parameter. - * - * @param \Drupal\filter\FilterBag $newFilterBag - * The desired FilterBag. - * - * @return \Drupal\filter\FilterFormatInterface - * The class instance this method is called on. - */ - public function setFilterBag($newFilterBag); + public function setCache($cache); } only in patch2: unchanged: --- /dev/null +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatMethodsTest.php @@ -0,0 +1,79 @@ + 'Filter format get and set methods', + 'description' => 'Test get and set methods on text format interface.', + 'group' => 'Filter', + ); + } + + function setUp() { + parent::setUp(); + + $this->format = entity_create('filter_format', array()); + $this->format->format = 'custom_format'; + $this->format->name = 'Custom format'; + $this->format->setFilterConfig('filter_url', array( + 'status' => 1, + 'settings' => array( + 'filter_url_length' => 30, + ), + )); + $this->format->save(); + } + + /** + * Tests weight get and set method. + */ + function testGetWeight() { + $weight = 0; + $this->assertIdentical(spl_object_hash($this->format->setWeight($weight)), spl_object_hash($this->format), format_string('Test weight set method for text format %format.', array('%format' => $this->format->name))); + $this->assertIdentical($this->format->getWeight(), $weight, format_string('Test weight get method for text format %format.', array('%format' => $this->format->name))); + } + + /** + * Tests roles get and set method. + */ + function testGetRoles() { + $roles = array(0,1); + $this->assertIdentical(spl_object_hash($this->format->setRoles($roles)), spl_object_hash($this->format), format_string('Test roles set method for text format %format.', array('%format' => $this->format->name))); + $this->assertIdentical($this->format->getRoles(), $roles, format_string('Test roles get method for text format %format.', array('%format' => $this->format->name))); + } + + /** + * Tests cache get and set method. + */ + function testIsCacheable() { + $is_cacheable = TRUE; + $this->assertIdentical(spl_object_hash($this->format->setCache($is_cacheable)), spl_object_hash($this->format), format_string('Test cache set method for text format %format.', array('%format' => $this->format->name))); + $this->assertIdentical($this->format->isCacheable(), $is_cacheable, format_string('Test cache get method for text format %format.', array('%format' => $this->format->name))); + } +}