working on db interface
This commit is contained in:
parent
bafa092e48
commit
975f8c9b4b
|
@ -2,8 +2,9 @@
|
||||||
<head>
|
<head>
|
||||||
<title>LayoutConstructorsTest</title>
|
<title>LayoutConstructorsTest</title>
|
||||||
<script type="text/javascript" src="testcase.js"></script>
|
<script type="text/javascript" src="testcase.js"></script>
|
||||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
|
<script type="text/javascript" src="prototype.js"></script>
|
||||||
<script type="text/javascript" src="FloatedDivConstructor.js"></script>
|
<script type="text/javascript" src="FloatedDivConstructor.js"></script>
|
||||||
|
<script type="text/javascript" src="TableConstructor.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -239,7 +240,41 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var TableConstructorTest = TestCase.create({
|
||||||
|
name: "Table Constructor Test",
|
||||||
|
|
||||||
|
testGenerateHTML: function() {
|
||||||
|
var myThis = this;
|
||||||
|
[
|
||||||
|
{
|
||||||
|
'input': {
|
||||||
|
'left': {
|
||||||
|
'active': false,
|
||||||
|
'start': 0,
|
||||||
|
'end': 3
|
||||||
|
},
|
||||||
|
'right': {
|
||||||
|
'active': false,
|
||||||
|
'start': 0,
|
||||||
|
'end': 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'expected_result': '<table id="container" cellspacing="0">\n' +
|
||||||
|
' <tr><td id="header"><?php echo $header ?></td></tr>\n' +
|
||||||
|
' <tr><td id="comic"><?php echo $comic ?></td></tr>\n' +
|
||||||
|
' <tr><td id="body"><?php echo $body ?></td></tr>\n' +
|
||||||
|
' <tr><td id="footer"><?php echo $footer ?></td></tr>\n' +
|
||||||
|
'</table>'
|
||||||
|
}
|
||||||
|
].each(function(info) {
|
||||||
|
var f = new FloatedDivConstructor();
|
||||||
|
myThis.assertEqual(info.expected_result, f.generate_html(info.input));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
FloatedDivConstructorTest.run();
|
FloatedDivConstructorTest.run();
|
||||||
|
TableConstructorTest.run();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -13,17 +13,19 @@ class ComicPressDBInterface {
|
||||||
}
|
}
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _get_categories() {
|
||||||
|
return get_categories("hide_empty=0");
|
||||||
|
}
|
||||||
|
|
||||||
function set_comic_categories($categories) {
|
function set_comic_categories($categories) {
|
||||||
$this->_non_comic_categories = array();
|
$this->_non_comic_categories = array();
|
||||||
$this->_all_categories = array();
|
$this->_all_categories = array();
|
||||||
foreach (get_categories("hide_empty=0") as $category_object) {
|
foreach ($this->_get_categories() as $category_object) {
|
||||||
$this->_all_categories[] = $category_object->term_id;
|
$this->_all_categories[] = $category_object->term_id;
|
||||||
if (!in_array($category_object->term_id, $categories
|
|
||||||
$this->categories_by_id[$category_object->term_id] = $category_object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_categories = $categories;
|
$this->_non_comic_categories = array_values(array_diff($this->_all_categories, $categories));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +93,7 @@ class ComicPressDBInterface {
|
||||||
* Get the next comic from the current one.
|
* Get the next comic from the current one.
|
||||||
*/
|
*/
|
||||||
function get_next_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, true, $override_post); }
|
function get_next_comic($category = null, $override_post = null) { return $this->get_adjacent_comic($category, true, $override_post); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<div class="post-comic-head"></div>
|
<div class="post-comic-head"></div>
|
||||||
<div class="post-comic">
|
<div class="post-comic">
|
||||||
<div class="comicarchiveframe">
|
<div class="comicarchiveframe">
|
||||||
<a href="<?php the_permalink() ?>"><img src="<?php the_comic_archive() ?>" alt="Click for full size." title="Click for full size" /><br />
|
<a href="<?php the_permalink() ?>"><?php do_action('show_archive') ?></a>
|
||||||
<h3><?php the_title() ?></h3>
|
<br />
|
||||||
|
<h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
|
||||||
<small><?php the_time('F jS, Y') ?></small></a>
|
<small><?php the_time('F jS, Y') ?></small></a>
|
||||||
</div>
|
</div>
|
||||||
<br class="clear-margins" />
|
<br class="clear-margins" />
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
comicpress_init();
|
comicpress_init();
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
include_partial('search-results-count');
|
include_partial('search-results-count');
|
||||||
|
|
||||||
if (have_posts()) {
|
if (have_posts()) {
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('MockPress/mockpress.php');
|
||||||
|
require_once('PHPUnit/Framework.php');
|
||||||
|
require_once(dirname(__FILE__) . '/../classes/ComicPressDBInterface.inc');
|
||||||
|
|
||||||
|
class ComicPressDBInterfaceTest extends PHPUnit_Framework_TestCase {
|
||||||
|
function testSingleton() {
|
||||||
|
$a = ComicPressDBInterface::get_instance();
|
||||||
|
$this->assertTrue(!isset($a->test));
|
||||||
|
$a->test = "test";
|
||||||
|
$this->assertEquals("test", $a->test);
|
||||||
|
|
||||||
|
$b = ComicPressDBInterface::get_instance();
|
||||||
|
$this->assertEquals("test", $b->test);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetComicCategories() {
|
||||||
|
$dbi = $this->getMock('ComicPressDBInterface', array('_get_categories'));
|
||||||
|
|
||||||
|
$dbi->expects($this->once())->method('_get_categories')->will($this->returnValue(array(
|
||||||
|
(object)array('term_id' => 1),
|
||||||
|
(object)array('term_id' => 2),
|
||||||
|
(object)array('term_id' => 3),
|
||||||
|
(object)array('term_id' => 4)
|
||||||
|
)));
|
||||||
|
|
||||||
|
$dbi->set_comic_categories(array(2,3));
|
||||||
|
|
||||||
|
$this->assertEquals(array(1,2,3,4), $dbi->_all_categories);
|
||||||
|
$this->assertEquals(array(1,4), $dbi->_non_comic_categories);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -132,7 +132,7 @@ class ComicPressStorylineTest extends PHPUnit_Framework_TestCase {
|
||||||
'3' => array('prior' => 2, 'previous' => 2)
|
'3' => array('prior' => 2, 'previous' => 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected_navigation, $this->css->get_valid_storyline_nav(1));
|
$this->assertEquals($expected_navigation, $this->css->get_valid_nav(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue