diff --git a/tests/example/README.txt b/tests/example/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..c781e9c91bf9b4d7c2d7a6d9e9499853460065a5 --- /dev/null +++ b/tests/example/README.txt @@ -0,0 +1,43 @@ +; $Id$ + +Example library + +Version 2 + +This file is an example file to test version detection. + +The various other files in this directory are to test the loading of JavaScript, +CSS and PHP files. +- JavaScript: The filenames of the JavaScript files are asserted to be in the + raw HTML via SimpleTest. Since the filename could appear, for instance, in an + error message, this is not very robust. Explicit testing of JavaScript, + though, is not yet possible with SimpleTest. Hence, the JavaScript files, if + loaded, insert a div with the id 'libraries-test' after the page title and put + some sample text in it of the form: "If this text shows up, the JavaScript + file was loaded successfully. If this text is [color], the CSS file was loaded + successfully." [color] is either 'red', 'green', 'orange' or 'blue' (see + below). If you enable SimpleTest's verbose mode and see the above text in one + of the debug pages, a JavaScript file was loaded successfully. Which file + depends on the color that is mentioned in the shown text (see below). +- CSS: The filenames of the CSS files are asserted to be in the raw HTML via + SimpleTest. Since the filename could appear, for instance, in an error + message, this is not very robust. Explicit testing of CSS, though, is not yet + possible with SimpleTest. Hence, the CSS files, if loaded, make the text that + was inserted via JavaScipt (see above) a certain color. If you enable + SimpleTest's verbose mode, and see the above text in a certain color (i.e. not + in black), a CSS file was loaded successfully. Which file depends on the + color: + - example_1: red + - example_2: green + - example_3: orange + - example_4: blue + Note that, because the CSS affects a div that is inserted via JavaScript, the + testing of CSS loading with this method is dependent on JavaScript loading. +- PHP: The loading of PHP files is tested by defining a dummy function in the + PHP files and then checking whether this function was defined using + function_exists(). This can be checked programatically with SimpleTest. +The loading of integration files is tested with the same method. The integration +files are libraries_test.js, libraries_test.css, libraries_test.inc and are +located in the tests directory alongside libraries_test.module (i.e. they are +not in the same directory as this file). The color that the JavaScript and CSS +integration files refer to is purple. diff --git a/tests/example/example_1.css b/tests/example/example_1.css new file mode 100644 index 0000000000000000000000000000000000000000..12ec7aa96cb4ad9b6169bc564a8049f7585274e6 --- /dev/null +++ b/tests/example/example_1.css @@ -0,0 +1,13 @@ +/* $Id$ */ + +/** + * @file + * Test CSS file for Libraries loading. + * + * Color the 'libraries-test' div red. See example_installed.txt for more + * information. + */ + +div#libraries-test { + color: red; +} diff --git a/tests/example/example_1.js b/tests/example/example_1.js new file mode 100644 index 0000000000000000000000000000000000000000..0a46b8a5371491609942cfb965e2180bbc316784 --- /dev/null +++ b/tests/example/example_1.js @@ -0,0 +1,19 @@ +// $Id$ + +/** + * @file + * Test JavaScript file for Libraries loading. + * + * Insert a 'libraries-test' div and some text below the page title. See + * example_installed.txt for more information. + */ + +(function ($) { + +Drupal.behaviors.librariesTest = { + attach: function(context, settings) { + $('h1#page-title').after('
If this text shows up, the JavaScript file was loaded successfully. If this text is red, the CSS file was loaded successfully.
') + } +}; + +})(jQuery); diff --git a/tests/example/example_1.php b/tests/example/example_1.php new file mode 100644 index 0000000000000000000000000000000000000000..7b4afdc711a56528520d6c264c147979cfbe4c83 --- /dev/null +++ b/tests/example/example_1.php @@ -0,0 +1,13 @@ +If this text shows up, the JavaScript file was loaded successfully. If this text is green, the CSS file was loaded successfully.') + } +}; + +})(jQuery); diff --git a/tests/example/example_2.php b/tests/example/example_2.php new file mode 100644 index 0000000000000000000000000000000000000000..c0b8a98a4fb3113d0c7cb99d4a2f15acb22a9d62 --- /dev/null +++ b/tests/example/example_2.php @@ -0,0 +1,13 @@ +If this text shows up, the JavaScript file was loaded successfully. If this text is orange, the CSS file was loaded successfully.') + } +}; + +})(jQuery); diff --git a/tests/example/example_3.php b/tests/example/example_3.php new file mode 100644 index 0000000000000000000000000000000000000000..9b3b492b0e63c791ef399e0f907eb699813fce4a --- /dev/null +++ b/tests/example/example_3.php @@ -0,0 +1,13 @@ +If this text shows up, the JavaScript file was loaded successfully. If this text is blue, the CSS file was loaded successfully.') + } +}; + +})(jQuery); diff --git a/tests/example/example_4.php b/tests/example/example_4.php new file mode 100644 index 0000000000000000000000000000000000000000..78992090abf78b944c8ef0edd2c5cfdeb6b98f4d --- /dev/null +++ b/tests/example/example_4.php @@ -0,0 +1,13 @@ +