From 0ef04790d1ae9d3b27b8d389235f9c5f29b65a95 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Aug 2015 11:30:43 +0200 Subject: renamed test file --- _test/tests/general/general_languagelint.php | 47 ----------------------- _test/tests/general/general_languagelint.test.php | 47 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 _test/tests/general/general_languagelint.php create mode 100644 _test/tests/general/general_languagelint.test.php (limited to '_test') diff --git a/_test/tests/general/general_languagelint.php b/_test/tests/general/general_languagelint.php deleted file mode 100644 index c11462640..000000000 --- a/_test/tests/general/general_languagelint.php +++ /dev/null @@ -1,47 +0,0 @@ -checkFiles(glob(DOKU_INC.'inc/lang/*/*.php')); - } - - function test_plugins() { - $this->checkFiles(glob(DOKU_INC.'lib/plugins/*/lang/*/*.php')); - } - - /** - * Run checks over the given PHP language files - * - * @param $files - */ - private function checkFiles($files){ - foreach($files as $file){ - // try to load the file - include $file; - // check it defines an array - $this->assertTrue(is_array($lang), $file); - unset($lang); - - $this->checkUgly($file); - } - } - - /** - * Checks if the file contains any ugly things like leading whitespace, BOM or trailing - * PHP closing mark - * - * @param $file - * @throws Exception - */ - private function checkUgly($file){ - $content = rtrim(file_get_contents($file)); - if(substr($content,0,5) != '') - throw new Exception("$file ends with '?>' - remove it!"); - } - -} diff --git a/_test/tests/general/general_languagelint.test.php b/_test/tests/general/general_languagelint.test.php new file mode 100644 index 000000000..c11462640 --- /dev/null +++ b/_test/tests/general/general_languagelint.test.php @@ -0,0 +1,47 @@ +checkFiles(glob(DOKU_INC.'inc/lang/*/*.php')); + } + + function test_plugins() { + $this->checkFiles(glob(DOKU_INC.'lib/plugins/*/lang/*/*.php')); + } + + /** + * Run checks over the given PHP language files + * + * @param $files + */ + private function checkFiles($files){ + foreach($files as $file){ + // try to load the file + include $file; + // check it defines an array + $this->assertTrue(is_array($lang), $file); + unset($lang); + + $this->checkUgly($file); + } + } + + /** + * Checks if the file contains any ugly things like leading whitespace, BOM or trailing + * PHP closing mark + * + * @param $file + * @throws Exception + */ + private function checkUgly($file){ + $content = rtrim(file_get_contents($file)); + if(substr($content,0,5) != '') + throw new Exception("$file ends with '?>' - remove it!"); + } + +} -- cgit v1.2.3 From 08099e4fe1e56308bc42cc639d187863088494bd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 18 Aug 2015 19:28:45 +0200 Subject: Form: correctly set type attribute for inputs #1312 --- _test/tests/inc/form/checkableelement.test.php | 2 ++ _test/tests/inc/form/inputelement.test.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/form/checkableelement.test.php b/_test/tests/inc/form/checkableelement.test.php index a0e4173e8..e1491f6ec 100644 --- a/_test/tests/inc/form/checkableelement.test.php +++ b/_test/tests/inc/form/checkableelement.test.php @@ -23,6 +23,7 @@ class form_checkableelement_test extends DokuWikiTest { $this->assertEquals('second', pq($inputs->elements[1])->val()); $this->assertEquals('checked', pq($inputs->elements[0])->attr('checked')); $this->assertEquals('', pq($inputs->elements[1])->attr('checked')); + $this->assertEquals('radio', pq($inputs->elements[0])->attr('type')); } /** @@ -45,5 +46,6 @@ class form_checkableelement_test extends DokuWikiTest { $this->assertEquals('second', pq($inputs->elements[1])->val()); $this->assertEquals('', pq($inputs->elements[0])->attr('checked')); $this->assertEquals('checked', pq($inputs->elements[1])->attr('checked')); + $this->assertEquals('radio', pq($inputs->elements[0])->attr('type')); } } diff --git a/_test/tests/inc/form/inputelement.test.php b/_test/tests/inc/form/inputelement.test.php index 7a5e6d2ea..3257d2a89 100644 --- a/_test/tests/inc/form/inputelement.test.php +++ b/_test/tests/inc/form/inputelement.test.php @@ -14,6 +14,7 @@ class form_inputelement_test extends DokuWikiTest { $input = $pq->find('input[name=foo]'); $this->assertTrue($input->length == 1); $this->assertEquals('this is text', $input->val()); + $this->assertEquals('text', $input->attr('type')); $label = $pq->find('label'); $this->assertTrue($label->length == 1); @@ -38,4 +39,20 @@ class form_inputelement_test extends DokuWikiTest { $this->assertEquals('a new text', $input->val()); } + function test_password() { + $form = new Form\Form(); + $form->addPasswordInput('foo', 'label text')->val('this is text'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('input[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('this is text', $input->val()); + $this->assertEquals('password', $input->attr('type')); + + $label = $pq->find('label'); + $this->assertTrue($label->length == 1); + $this->assertEquals('label text', $label->find('span')->text()); + } } -- cgit v1.2.3 From 8f0df229ed3e82191f118594ea5145c9d5942d7b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 18 Aug 2015 20:12:32 +0200 Subject: Form: added Button element #1312 --- _test/tests/inc/form/buttonelement.test.php | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 _test/tests/inc/form/buttonelement.test.php (limited to '_test') diff --git a/_test/tests/inc/form/buttonelement.test.php b/_test/tests/inc/form/buttonelement.test.php new file mode 100644 index 000000000..8e1a7e1e2 --- /dev/null +++ b/_test/tests/inc/form/buttonelement.test.php @@ -0,0 +1,40 @@ +addButton('foo', 'Hello World')->val('bam')->attr('type', 'submit'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('button[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('bam', $input->val()); + $this->assertEquals('submit', $input->attr('type')); + $this->assertEquals('Hello World', $input->text()); // tags were escaped + + $b = $input->find('b'); // no tags found + $this->assertTrue($b->length == 0); + } + + function test_html() { + $form = new Form\Form(); + $form->addButtonHTML('foo', 'Hello World')->val('bam')->attr('type', 'submit'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('button[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('bam', $input->val()); + $this->assertEquals('submit', $input->attr('type')); + $this->assertEquals('Hello World', $input->text()); // tags are stripped here + + $b = $input->find('b'); // tags found + $this->assertTrue($b->length == 1); + } +} -- cgit v1.2.3 From d09fc643d601f95006c6144c72bfde3e399ef811 Mon Sep 17 00:00:00 2001 From: Phil Hopper Date: Thu, 20 Aug 2015 14:51:16 -0400 Subject: Fix Parser Media tests running locally These tests were passing on travis-ci but failing when run locally because the tests were assuming the value of DOKU_BASE would be '/./' but it was actually '/tmp/' instead. --- _test/tests/inc/parser/parser_media.test.php | 69 ++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/parser_media.test.php b/_test/tests/inc/parser/parser_media.test.php index d9a0626f5..abbcfe213 100644 --- a/_test/tests/inc/parser/parser_media.test.php +++ b/_test/tests/inc/parser/parser_media.test.php @@ -30,12 +30,21 @@ class TestOfDoku_Parser_Media extends TestOfDoku_Parser { $source = ''; $this->assertEquals(substr($url,67,64),$source); // work around random token - $a_first_part = 'assertEquals(substr($url,132,45),$a_first_part); - $this->assertEquals(substr($url,183,121),$a_second_part); + + $substr_start = 132; + $substr_len = strlen($a_first_part); + $this->assertEquals($a_first_part, substr($url, $substr_start, $substr_len)); + + $substr_start = strpos($url, '&media', $substr_start + $substr_len); + $this->assertNotSame(false, $substr_start, 'Substring not found.'); + $substr_len = strlen($a_second_part); + $this->assertEquals($a_second_part, substr($url, $substr_start, $substr_len)); + $rest = 'away.ogv'."\n"; - $this->assertEquals(substr($url,304),$rest); + $substr_start = strlen($url) - strlen($rest); + $this->assertEquals($rest, substr($url, $substr_start)); } /** @@ -58,12 +67,21 @@ class TestOfDoku_Parser_Media extends TestOfDoku_Parser { $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true); // work around random token - $a_first_part = ''; - $this->assertEquals(substr($url,0,34),$a_first_part); - $this->assertEquals(substr($url,40,121),$a_second_part); + + $substr_start = 0; + $substr_len = strlen($a_first_part); + $this->assertEquals($a_first_part, substr($url, $substr_start, $substr_len)); + + $substr_start = strpos($url, '&media', $substr_start + $substr_len); + $this->assertNotSame(false, $substr_start, 'Substring not found.'); + $substr_len = strlen($a_second_part); + $this->assertEquals($a_second_part, substr($url, $substr_start, $substr_len)); + $rest = 'away.vid'; - $this->assertEquals(substr($url,161),$rest); + $substr_start = strlen($url) - strlen($rest); + $this->assertEquals($rest, substr($url, $substr_start)); } @@ -84,20 +102,33 @@ class TestOfDoku_Parser_Media extends TestOfDoku_Parser { $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file,null,null,null,null,'cache','details',true); - $video = '