diff options
author | lisps <stummp@loewen.de> | 2014-09-26 12:48:02 +0200 |
---|---|---|
committer | lisps <stummp@loewen.de> | 2014-09-26 12:48:02 +0200 |
commit | 8d39e80d363eda2ef31dac8473bfdab4b9cd7ce5 (patch) | |
tree | 7bab1caccbc0de7c30f0e610d1e5ee9b3c67d564 /_test | |
parent | 115aab0f5fca76360c50f759f587229ff327105d (diff) | |
parent | 7b950f2d59050052c1d9251b0bd9bd40c7441040 (diff) | |
download | rpg-8d39e80d363eda2ef31dac8473bfdab4b9cd7ce5.tar.gz rpg-8d39e80d363eda2ef31dac8473bfdab4b9cd7ce5.tar.bz2 |
Merge remote-tracking branch master into revisions
Diffstat (limited to '_test')
-rw-r--r-- | _test/README | 56 | ||||
-rw-r--r-- | _test/phpunit.xml | 5 | ||||
-rw-r--r-- | _test/tests/inc/PassHash.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/auth_password.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/cache_use.test.php | 64 | ||||
-rw-r--r-- | _test/tests/inc/cli_options.test.php | 56 | ||||
-rw-r--r-- | _test/tests/inc/init_checkssl.test.php | 81 | ||||
-rw-r--r-- | _test/tests/inc/input.test.php | 19 | ||||
-rw-r--r-- | _test/tests/inc/io_rmdir.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/parser/parser.inc.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/parser/parser_quotes.test.php | 131 | ||||
-rw-r--r-- | _test/tests/inc/parser/parser_table.test.php | 299 | ||||
-rw-r--r-- | _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 2 | ||||
-rw-r--r-- | _test/tests/inc/parserutils_get_renderer.test.php | 4 | ||||
-rw-r--r-- | _test/tests/inc/tar.test.php | 50 | ||||
-rw-r--r-- | _test/tests/inc/utf8_romanize.test.php | 2 | ||||
-rw-r--r-- | _test/tests/lib/exe/css_css_compress.test.php | 15 |
17 files changed, 686 insertions, 106 deletions
diff --git a/_test/README b/_test/README index 5220248b2..f0db2a550 100644 --- a/_test/README +++ b/_test/README @@ -9,35 +9,28 @@ This is the test suite to automatically test various parts of DokuWiki. ===== PHPUnit Installation ====== -==== via PEAR installer ==== +You can install phpunit through your distribution's package manager or simply +download the newest phar file into the _test directory: - pear config-set auto_discover 1 - pear install pear.phpunit.de/PHPUnit - -==== via Composer ==== - -Include a composer.json file in your project, which can be as minimal as: - -<code> -{ - "require-dev": { - "phpunit/phpunit": "3.7.*" - } -} -</code> - -==== via PHP archive (PHAR) ==== - -Download http://pear.phpunit.de/get/phpunit.phar and make it executable on your system. + cd _test/ + wget https://phar.phpunit.de/phpunit.phar ===== Running all tests ===== -Just change to the ''_test'' directory and run phpunit: +Just change to the ''_test'' directory and run phpunit (depending on your install +method): cd _test/ phpunit +or + + cd _test/ + php phpunit.phar + +===== Troubleshooting ===== + PHPUnit will fail on some systems with a //headers already sent// error. This is a known problem with PHPUnit, the error can be avoided by passing the '--stderr' flag to phpunit: @@ -46,8 +39,10 @@ This is a known problem with PHPUnit, the error can be avoided by passing the On windows you may have to enable OpenSSL support for https tests. Some of them point to httpclient_http.tests.php on the failure. -To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder -and add the following line to your php.ini in the extension section: +To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' +to your ''windows\system32'' folder and add the following line to your php.ini +in the extension section: + <code ini> extension=php_openssl.dll </code> @@ -56,13 +51,13 @@ extension=php_openssl.dll You can run a single test file by providing it as an argument to phpunit: - phpunit --stderr tests/inc/common_cleanText.test.php + phpunit tests/inc/common_cleanText.test.php You can also use groups to exclude certain test from running. For example use the following command to avoid long running test or tests accessing the Internet. - phpunit --stderr --exclude-group slow,internet + phpunit --exclude-group slow,internet ===== Create new Tests ===== @@ -71,23 +66,10 @@ folder. Please respect the folder structure and naming convention. Inside the file, implement a class, extending 'DokuWikiTest'. Every method, starting with 'test' will be called as a test (e.g. 'testIfThisIsValid'); - ===== TODO for the test framework ===== - * test cross platform compatibility: especially test windows - * update http://www.dokuwiki.org/devel:unittesting * optional: add helper methods to TestRequest for easy form submission * createForm(), ... * check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers -===== Migration Protocol ===== - -The following tests were not migrated: - - * inc/indexer_idx_indexlengths (fs dependencies) - * inc/mail_send (integration test) - * inc/parser/parser_formatting - * inc/parser/xhtml_htmlphp (runkit) - * inc/parser/xhtml_links - diff --git a/_test/phpunit.xml b/_test/phpunit.xml index fc7dd8be0..25506b1ae 100644 --- a/_test/phpunit.xml +++ b/_test/phpunit.xml @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="bootstrap.php" - convertNoticesToExceptions="false"> + convertNoticesToExceptions="false" + colors="true" + stderr="true" + > <testsuites> <testsuite name="DokuWiki Tests"> diff --git a/_test/tests/inc/PassHash.test.php b/_test/tests/inc/PassHash.test.php index b6cb07090..1d34aa696 100644 --- a/_test/tests/inc/PassHash.test.php +++ b/_test/tests/inc/PassHash.test.php @@ -5,7 +5,7 @@ * * most tests are in auth_password.test.php */ -class PassHash_test extends PHPUnit_Framework_TestCase { +class PassHash_test extends DokuWikiTest { function test_hmac(){ // known hashes taken from https://code.google.com/p/yii/issues/detail?id=1942 diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php index 27e03be60..07b9f5bb2 100644 --- a/_test/tests/inc/auth_password.test.php +++ b/_test/tests/inc/auth_password.test.php @@ -1,6 +1,6 @@ <?php -class auth_password_test extends PHPUnit_Framework_TestCase { +class auth_password_test extends DokuWikiTest { // hashes for the password foo$method, using abcdefgh as salt var $passes = array( diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php index f5349df13..3ea212d50 100644 --- a/_test/tests/inc/cache_use.test.php +++ b/_test/tests/inc/cache_use.test.php @@ -10,27 +10,77 @@ class cache_use_test extends DokuWikiTest { private $cache; function setUp() { - global $ID; + global $ID, $conf; parent::setUp(); $ID = 'cached'; $file = wikiFN($ID); + $conf['cachetime'] = 0; // ensure the value is not -1, which disables caching saveWikiText($ID, 'Content', 'Created'); - // set the modification time a second in the past in order to ensure that the cache is newer than the page - touch($file, time()-1); - # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering - $this->cache = new cache_renderer($ID, $file, 'metadata'); + $this->cache = new cache_renderer($ID, $file, 'xhtml'); $this->cache->storeCache('Test'); + + // set the modification times explicitly (overcome Issue #694) + $time = time(); + touch($file, $time-1); + touch($this->cache->cache, $time); } function test_use() { + $this->markTestSkipped('Disabled until Ticket #694 has been fixed'); + return; + $this->assertTrue($this->cache->useCache()); } - + /** + * In all the following tests the cache should not be usable + * as such, they are meaningless if test_use didn't pass. + * + * @depends test_use + */ function test_purge() { - $this->assertFalse($this->cache->useCache(array('purge' => true))); + /* @var Input $INPUT */ + global $INPUT; + $INPUT->set('purge',1); + + $this->assertFalse($this->cache->useCache()); + $this->assertNotEmpty($this->cache->depends['purge']); + } + + /** + * @depends test_use + */ + function test_filedependency() { + // give the dependent src file the same mtime as the cache + touch($this->cache->file, filemtime($this->cache->cache)); + $this->assertFalse($this->cache->useCache()); + } + + /** + * @depends test_use + */ + function test_age() { + // need to age both our source file & the cache + $age = 10; + $time = time() - $age - 1; // older than age + + touch($this->cache->file, $time - 1); + touch($this->cache->cache, $time); + + $this->assertFalse($this->cache->useCache(array('age' => $age))); + } + + /** + * @depends test_use + */ + function test_confnocaching() { + global $conf; + $conf['cachetime'] = -1; // disables renderer caching + + $this->assertFalse($this->cache->useCache()); + $this->assertNotEmpty($this->cache->_nocache); } }
\ No newline at end of file diff --git a/_test/tests/inc/cli_options.test.php b/_test/tests/inc/cli_options.test.php new file mode 100644 index 000000000..ab03ee29b --- /dev/null +++ b/_test/tests/inc/cli_options.test.php @@ -0,0 +1,56 @@ +<?php + +class cli_options extends DokuWikiTest { + + function test_simpleshort() { + $options = new DokuCLI_Options(); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); + + $options->args = array('-x', 'foo', 'bang'); + $options->parseOptions(); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $options->args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_simplelong1() { + $options = new DokuCLI_Options(); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); + + $options->args = array('--exclude', 'foo', 'bang'); + $options->parseOptions(); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $options->args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_simplelong2() { + $options = new DokuCLI_Options(); + $options->registerOption('exclude', 'exclude files', 'x', 'file'); + + $options->args = array('--exclude=foo', 'bang'); + $options->parseOptions(); + + $this->assertEquals('foo', $options->getOpt('exclude')); + $this->assertEquals(array('bang'), $options->args); + $this->assertFalse($options->getOpt('nothing')); + } + + function test_complex() { + $options = new DokuCLI_Options(); + + $options->registerOption('plugins', 'run on plugins only', 'p'); + $options->registerCommand('status', 'display status info'); + $options->registerOption('long', 'display long lines', 'l', false, 'status'); + + $options->args = array('-p', 'status', '--long', 'foo'); + $options->parseOptions(); + + $this->assertEquals('status', $options->getCmd()); + $this->assertTrue($options->getOpt('plugins')); + $this->assertTrue($options->getOpt('long')); + $this->assertEquals(array('foo'), $options->args); + } +}
\ No newline at end of file diff --git a/_test/tests/inc/init_checkssl.test.php b/_test/tests/inc/init_checkssl.test.php new file mode 100644 index 000000000..c57d3c37e --- /dev/null +++ b/_test/tests/inc/init_checkssl.test.php @@ -0,0 +1,81 @@ +<?php + +class init_checkssl_test extends DokuWikiTest { + + /** + * Running behind an SSL proxy, HTTP between server and proxy + * HTTPS not set + * HTTP_X_FORWARDED_PROTO + * set to https + */ + function test1() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; + + $this->assertEquals(is_ssl(), true); + } + + /** + * Running behind a plain HTTP proxy, HTTP between server and proxy + * HTTPS not set + * HTTP_X_FORWARDED_PROTO set to http + */ + function test2() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http'; + + $this->assertEquals(is_ssl(), false); + } + + /** + * Running behind an SSL proxy, HTTP between server and proxy + * HTTPS set to off, + * HTTP_X_FORWARDED_PROTO set to https + */ + function test3() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; + $_SERVER['HTTPS'] = 'off'; + + $this->assertEquals(is_ssl(), true); + } + + /** + * Not running behind a proxy, HTTPS server + * HTTPS set to on, + * HTTP_X_FORWARDED_PROTO not set + */ + function test4() { + $_SERVER['HTTPS'] = 'on'; + + $this->assertEquals(is_ssl(), true); + } + + /** + * Not running behind a proxy, plain HTTP server + * HTTPS not set + * HTTP_X_FORWARDED_PROTO not set + */ + function test5() { + $this->assertEquals(is_ssl(), false); + } + + /** + * Not running behind a proxy, plain HTTP server + * HTTPS set to off + * HTTP_X_FORWARDED_PROTO not set + */ + function test6() { + $_SERVER['HTTPS'] = 'off'; + $this->assertEquals(is_ssl(), false); + } + + /** + * Running behind an SSL proxy, SSL between proxy and HTTP server + * HTTPS set to on, + * HTTP_X_FORWARDED_PROTO set to https + */ + function test7() { + $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; + $_SERVER['HTTPS'] = 'on'; + + $this->assertEquals(is_ssl(), true); + } +} diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 59b5ea4b9..cec0b80f6 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -214,6 +214,25 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } + public function test_valid(){ + $_REQUEST = $this->data; + $_POST = $this->data; + $_GET = $this->data; + $INPUT = new Input(); + + $valids = array(17, 'foo'); + $this->assertSame(null, $INPUT->valid('nope', $valids)); + $this->assertSame('bang', $INPUT->valid('nope', $valids, 'bang')); + $this->assertSame(17, $INPUT->valid('int', $valids)); + $this->assertSame('foo', $INPUT->valid('string', $valids)); + $this->assertSame(null, $INPUT->valid('array', $valids)); + + $valids = array(true); + $this->assertSame(true, $INPUT->valid('string', $valids)); + $this->assertSame(true, $INPUT->valid('one', $valids)); + $this->assertSame(null, $INPUT->valid('zero', $valids)); + } + public function test_extract(){ $_REQUEST = $this->data; $_POST = $this->data; diff --git a/_test/tests/inc/io_rmdir.test.php b/_test/tests/inc/io_rmdir.test.php index 3de57fa86..1c0eccb38 100644 --- a/_test/tests/inc/io_rmdir.test.php +++ b/_test/tests/inc/io_rmdir.test.php @@ -4,7 +4,7 @@ class io_rmdir_test extends DokuWikiTest { function test_nopes(){ // set up test dir - $dir = io_mktmpdir(); + $dir = realpath(io_mktmpdir()); $top = dirname($dir); $this->assertTrue($dir !== false); $this->assertTrue(is_dir($dir)); diff --git a/_test/tests/inc/parser/parser.inc.php b/_test/tests/inc/parser/parser.inc.php index 61f15678b..f1207b119 100644 --- a/_test/tests/inc/parser/parser.inc.php +++ b/_test/tests/inc/parser/parser.inc.php @@ -3,7 +3,7 @@ require_once DOKU_INC . 'inc/parser/parser.php'; require_once DOKU_INC . 'inc/parser/handler.php'; -abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase { +abstract class TestOfDoku_Parser extends DokuWikiTest { var $P; var $H; diff --git a/_test/tests/inc/parser/parser_quotes.test.php b/_test/tests/inc/parser/parser_quotes.test.php index b82328212..6f174ddae 100644 --- a/_test/tests/inc/parser/parser_quotes.test.php +++ b/_test/tests/inc/parser/parser_quotes.test.php @@ -10,8 +10,9 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { } function testSingleQuoteOpening() { + $raw = "Foo 'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -23,12 +24,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteOpeningSpecial() { + $raw = "Foo said:'hello Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo said:'hello Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -40,12 +42,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosing() { + $raw = "Foo hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -57,12 +60,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuoteClosingSpecial() { + $raw = "Foo hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -74,12 +78,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotes() { + $raw = "Foo 'hello' Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo 'hello' Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -93,12 +98,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testApostrophe() { + $raw = "hey it's fine weather today"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("hey it's fine weather today"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -110,13 +116,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testSingleQuotesSpecial() { + $raw = "Foo ('hello') Bar"; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse("Foo ('hello') Bar"); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -130,12 +137,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpening() { + $raw = 'Foo "hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -147,12 +155,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteOpeningSpecial() { + $raw = 'Foo said:"hello Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo said:"hello Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -164,12 +173,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosing() { + $raw = 'Foo hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello" Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -181,12 +192,14 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuoteClosingSpecial() { + $raw = 'Foo hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo hello") Bar'); + $this->H->status['doublequote'] = 1; + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -198,12 +211,31 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + function testDoubleQuoteClosingSpecial2() { + $raw = 'Foo hello") Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->H->status['doublequote'] = 0; + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo hello')), + array('doublequoteopening',array()), + array('cdata',array(') Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotes() { + $raw = 'Foo "hello" Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo "hello" Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -217,12 +249,13 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); } function testDoubleQuotesSpecial() { + $raw = 'Foo ("hello") Bar'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('Foo ("hello") Bar'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -236,12 +269,54 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls, 'wikitext => '.$raw); + } + + function testDoubleQuotesEnclosingBrackets() { + $raw = 'Foo "{hello}" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('{hello}')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext - '.$raw); + } + + function testDoubleQuotesEnclosingLink() { + $raw = 'Foo "[[www.domain.com]]" Bar'; + $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); + $this->P->parse($raw); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('doublequoteopening',array()), + array('cdata',array('[[www.domain.com]]')), + array('doublequoteclosing',array()), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } + function testAllQuotes() { + $raw = 'There was written "He thought \'It\'s a man\'s world\'".'; $this->P->addMode('quotes',new Doku_Parser_Mode_Quotes()); - $this->P->parse('There was written "He thought \'It\'s a man\'s world\'".'); + $this->P->parse($raw); $calls = array ( array('document_start',array()), @@ -262,7 +337,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser { array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls,'wikitext => '.$raw); } } diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index bc19ebff9..a9b4e284c 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -44,7 +44,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableWinEOL() { @@ -84,7 +84,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testEmptyTable() { @@ -109,7 +109,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableHeaders() { @@ -143,7 +143,152 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testTableHead() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X ^ Y ^ Z ^ +| x | y | z | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 2, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' x ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' y ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' z ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(33)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testTableHeadOneRowTable() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X ^ Y ^ Z ^ +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 1, 6)), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('table_close',array(19)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testTableHeadMultiline() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ Y2 ^ Z2 ^ +| A | B | C | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 3, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Y2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' B ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(53)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } @@ -178,7 +323,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellSpan() { @@ -220,7 +365,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellRowSpan() { @@ -268,7 +413,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testCellRowSpanFirstRow() { @@ -326,9 +471,134 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } + function testRowSpanTableHead() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ ::: ^ Z2 ^ +| A3 | B3 | C3 | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 3, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,2)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' B3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C3 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(57)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + + function testRowSpanAcrossTableHeadBoundary() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +^ X1 ^ Y1 ^ Z1 ^ +^ X2 ^ ::: ^ Z2 ^ +| A3 | ::: | C3 | +| A4 | ::: | C4 | +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(3, 4, 6)), + array('tablethead_open',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,2)), + array('cdata',array(' Y1 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z1 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' X2 ')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array(' Z2 ')), + array('tableheader_close',array()), + array('tablerow_close',array()), + array('tablethead_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A3 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,2)), + array('cdata',array('')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C3 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' A4 ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' C4 ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('table_close',array(76)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); + + } + function testCellAlignmentFormatting() { $this->P->addMode('table',new Doku_Parser_Mode_Table()); $this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong')); @@ -365,7 +635,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } @@ -411,7 +681,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - formatting able to spread across cols @@ -466,7 +736,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - unformatted able to spread across cols @@ -517,7 +787,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTableLinebreak() { @@ -565,7 +835,7 @@ def'); array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } // This is really a failing test - footnote able to spread across cols @@ -624,7 +894,7 @@ def'); array('p_close',array()), array('document_end',array()), ); - $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + $this->assertEquals($calls,array_map('stripbyteindex',$this->H->calls)); } function testTable_FS1833() { @@ -646,4 +916,3 @@ def'); } } - diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index 7b43b6d62..dd1ed1d3f 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -5,7 +5,7 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; /** * Tests for Doku_Renderer::_resolveInterWiki() */ -class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { +class Test_resolveInterwiki extends DokuWikiTest { function testDefaults() { $Renderer = new Doku_Renderer(); diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php index 69aeb3b19..0f373227d 100644 --- a/_test/tests/inc/parserutils_get_renderer.test.php +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -45,10 +45,6 @@ class parserutils_get_renderer_test extends DokuWikiTest { } // test fallback fails - /** - * @expectedException PHPUnit_Framework_Error - * @expectedExceptionCode E_USER_WARNING - */ function test_p_get_renderer_fallback_fail() { global $conf; diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 417f1a853..15453b16d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -1,6 +1,38 @@ <?php class Tar_TestCase extends DokuWikiTest { + /** + * file extensions that several tests use + */ + protected $extensions = array('tar'); + + public function setUp() { + parent::setUp(); + if (extension_loaded('zlib')) { + $this->extensions[] = 'tgz'; + } + if (extension_loaded('bz2')) { + $this->extensions[] = 'tbz'; + } + } + + /* + * dependency for tests needing zlib extension to pass + */ + public function test_ext_zlib() { + if (!extension_loaded('zlib')) { + $this->markTestSkipped('skipping all zlib tests. Need zlib extension'); + } + } + + /* + * dependency for tests needing zlib extension to pass + */ + public function test_ext_bz2() { + if (!extension_loaded('bz2')) { + $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension'); + } + } /** * simple test that checks that the given filenames and contents can be grepped from @@ -58,8 +90,6 @@ class Tar_TestCase extends DokuWikiTest { $tar->addData('another/testdata3.txt', 'testcontent3'); $tar->close(); -copy ($tmp, '/tmp/test.tar'); - $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number $data = file_get_contents($tmp); @@ -89,7 +119,7 @@ copy ($tmp, '/tmp/test.tar'); public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -112,7 +142,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -138,7 +168,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -164,7 +194,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -190,7 +220,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -215,7 +245,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -249,6 +279,9 @@ copy ($tmp, '/tmp/test.tar'); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } + /** + * @depends test_ext_zlib + */ public function test_longpathextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); @@ -338,6 +371,7 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract a tarbomomb + * @depends test_ext_zlib */ public function test_tarbomb() { $dir = dirname(__FILE__).'/tar'; diff --git a/_test/tests/inc/utf8_romanize.test.php b/_test/tests/inc/utf8_romanize.test.php index d08346faa..353d48c00 100644 --- a/_test/tests/inc/utf8_romanize.test.php +++ b/_test/tests/inc/utf8_romanize.test.php @@ -5,7 +5,7 @@ if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1); /** * @group slow */ -class utf8_romanize_test extends PHPUnit_Framework_TestCase { +class utf8_romanize_test extends DokuWikiTest { /** * Check Japanese romanization diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index f0eb17968..807317ca6 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -53,6 +53,21 @@ class css_css_compress_test extends DokuWikiTest { $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); } + function test_slcom6(){ + $text = '#foo { + background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented + }'; + $this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_slcom7(){ + $text = '#foo a[href ^="https://"], #foo a[href ^=\'https://\'] { + background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is \'all\' "commented" + }'; + $this->assertEquals('#foo a[href ^="https://"],#foo a[href ^=\'https://\']{background-image:url(//foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_hack(){ $text = '/* Mac IE will not see this and continue with inline-block */ /* \\*/ |