diff --git a/codefilter.info b/codefilter.info deleted file mode 100644 index 89854d8..0000000 --- a/codefilter.info +++ /dev/null @@ -1,8 +0,0 @@ -name = Code Filter -description = Provides tags for automatically escaping and formatting large pieces of code. -core = 7.x -files[] = codefilter.module -files[] = codefilter.test - -stylesheets[screen][] = codefilter.css -scripts[] = codefilter.js diff --git a/codefilter.info.yml b/codefilter.info.yml new file mode 100644 index 0000000..7afcf85 --- /dev/null +++ b/codefilter.info.yml @@ -0,0 +1,4 @@ +name: 'Code Filter' +description: 'Provides tags for automatically escaping and formatting large pieces of code.' +core: '8.x' + diff --git a/codefilter.module b/codefilter.module index 70f0460..5718d19 100644 --- a/codefilter.module +++ b/codefilter.module @@ -140,6 +140,7 @@ function _codefilter_escape_php_tag_callback($matches) { function codefilter_filter_info() { $filters['codefilter'] = array( 'title' => t('Code filter'), + 'type' => FILTER_TYPE_MARKUP_LANGUAGE, 'description' => t('Allows users to post code verbatim using <code> and <?php ?> tags.'), 'prepare callback' => '_codefilter_prepare', 'process callback' => '_codefilter_process', @@ -208,3 +209,12 @@ function _codefilter_settings($form, &$form_state, $filter, $format, $defaults) ); return $elements; } + +/** + * Implements hook_page_build(). + */ +function codefilter_page_build(&$page) { + $path = drupal_get_path('module', 'codefilter'); + $page['#attached']['css'][] = $path . '/codefilter.css'; + $page['#attached']['js'][] = $path . '/codefilter.js'; +} diff --git a/codefilter.test b/lib/Drupal/codefilter/Tests/CodeFilterUnitTest.php similarity index 67% rename from codefilter.test rename to lib/Drupal/codefilter/Tests/CodeFilterUnitTest.php index a5166f6..155f029 100644 --- a/codefilter.test +++ b/lib/Drupal/codefilter/Tests/CodeFilterUnitTest.php @@ -1,52 +1,22 @@ t('Code Filter'), - 'description' => t('Ensure code wrapped in php or code tags renders as expected.'), - 'group' => t('Code Filter'), - ); - } - - function setUp() { - // Enable codefilter.module for testing. - parent::setup('codefilter'); - $this->web_editor = $this->drupalCreateUser(array('create article content')); - } +use Drupal\simpletest\DrupalUnitTestBase; +class CodeFilterUnitTest extends DrupalUnitTestBase { /** - * Creates an array in a format compatible with standard node 'body' fields. + * Modules to enable. * - * @param $value - * String to use as body text value. - * @return array - * An array suitable for saving in a node object body field. - * - * @see DrupalWebTestCase::drupalCreateNode(); + * @var array */ - protected function nodeBody($value) { - return array( - LANGUAGE_NONE => array( - array( - 'value' => $value, - ), - ), - ); - } - -} - -class CodeFilterUnitTestCase extends DrupalUnitTestCase { + public static $modules = array('codefilter'); // The filter object as returned from codefilter_filter_info(). private $filter; @@ -61,7 +31,6 @@ class CodeFilterUnitTestCase extends DrupalUnitTestCase { protected function setUp() { parent::setUp(); - include_once dirname(__FILE__) . '/codefilter.module'; $this->filter = codefilter_filter_info(); $this->path = drupal_get_path('module', 'codefilter') . '/tests'; } @@ -78,7 +47,7 @@ class CodeFilterUnitTestCase extends DrupalUnitTestCase { protected function filterText($text, $settings = array()) { $filter =& $this->filter['codefilter']; // Set up a dummy format using defaults. - $format = new stdClass(); + $format = new \stdClass(); $format->settings = array_merge($filter['default settings'], $settings); $text = call_user_func($filter['prepare callback'], $text, $format); $text = call_user_func($filter['process callback'], $text, $format); @@ -121,4 +90,3 @@ class CodeFilterUnitTestCase extends DrupalUnitTestCase { ); } } -