diff --git a/test/widgets/ArchiveDropdownWidgetTest.php b/test/widgets/ArchiveDropdownWidgetTest.php new file mode 100644 index 0000000..2eb1eaa --- /dev/null +++ b/test/widgets/ArchiveDropdownWidgetTest.php @@ -0,0 +1,61 @@ +w = new ArchiveDropdownWidget(); + } + + function providerTestBuildDropdown() { + return array( + array(null, 'Archives...', null, 'Go'), + array('Test', 'Test', 'Test2', 'Test2'), + ); + } + + /** + * @dataProvider providerTestBuildDropdown + */ + function testBuildDropdown($default_value, $expected_default, $button_value, $expected_button) { + if (!is_null($default_value)) { + _set_filter_expectation('comicpress_archive_dropdown_default_entry', $default_value); + } + + if (!is_null($button_value)) { + _set_filter_expectation('comicpress_archive_dropdown_submit_button', $button_value); + } + + foreach (array( + array('test' => 'Test', 'test2' => 'Test2'), + '' + ) as $entries) { + $html = $this->w->build_dropdown($entries); + + foreach (array( + array('tag' => 'div', 'attributes' => array('class' => 'archive-dropdown-wrap')), + array('tag' => 'form', 'attributes' => array('action' => '', 'method' => 'get')), + array('tag' => 'select', 'attributes' => array('name' => 'cp[urls]')), + array('tag' => 'input', 'attributes' => array('name' => 'cp[_nonce]')), + array('tag' => 'input', 'attributes' => array('name' => 'cp[_action_nonce]')), + array('tag' => 'input', 'attributes' => array('name' => 'cp[action]', 'value' => 'follow-archive-dropdown')), + array('tag' => 'option', 'attributes' => array('value' => ''), 'content' => $expected_default), + array('tag' => 'input', 'attributes' => array('type' => 'submit', 'value' => $expected_button)), + array('tag' => 'option', 'attributes' => array('value' => 'test'), 'content' => 'Test'), + array('tag' => 'option', 'attributes' => array('value' => 'test2'), 'content' => 'Test2'), + ) as $matcher) { + $this->assertTag($matcher, $html); + } + } + } + + function testBuildDropdownNotStringOrArray() { + $html = $this->w->build_dropdown(false); + + $this->assertTrue(empty($html)); + } +} \ No newline at end of file diff --git a/widgets/ArchiveDropdownWidget.inc b/widgets/ArchiveDropdownWidget.inc new file mode 100644 index 0000000..91057a8 --- /dev/null +++ b/widgets/ArchiveDropdownWidget.inc @@ -0,0 +1,133 @@ +create_structure(get_option('comicpress-storyline-category-order')); + $categories = array_keys($storyline->_structure); + foreach ($categories as $id) { + $post = ComicPressDBInterface::get_instance()->get_first_comic($id); + } +} +*/ + +function comicpress_archive_dropdown() { ?> +
/>Off
+