public function testGetBookContentArrayWithSeries() { $book = Book::getBookById(2); $test = JSONRenderer::getBookContentArray($book); $this->assertEquals("Sherlock Holmes", $test["seriesName"]); $this->assertEquals("6.0", $test["seriesIndex"]); $this->assertEquals("Book 6.0 in the Sherlock Holmes series", $test["seriesCompleteName"]); $this->assertStringEndsWith("?page=7&id=1", $test["seriesurl"]); }
public function testRenderCustomColumns() { global $config; $_SERVER["HTTP_USER_AGENT"] = "Firefox"; $config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; $_GET["custom"] = "11"; $config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); $config['cops_calibre_custom_column_list'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); $config['cops_calibre_custom_column_preview'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); Base::clearDb(); $book = Book::getBookById(223); $json = JSONRenderer::getBookContentArray($book); /* @var CustomColumn[] $custom */ $custom = $json["customcolumns_list"]; $this->assertEquals("custom_01", $custom[0]['customColumnType']['columnTitle']); $this->assertEquals("text_2", $custom[0]['htmlvalue']); $this->assertEquals("custom_02", $custom[1]['customColumnType']['columnTitle']); $this->assertEquals("a", $custom[1]['htmlvalue']); $this->assertEquals("custom_03", $custom[2]['customColumnType']['columnTitle']); $this->assertEquals("<div>Not Set</div>", $custom[2]['htmlvalue']); $this->assertEquals("custom_04", $custom[3]['customColumnType']['columnTitle']); $this->assertEquals("", $custom[3]['htmlvalue']); $this->assertEquals("custom_05", $custom[4]['customColumnType']['columnTitle']); $this->assertEquals("val05", $custom[4]['htmlvalue']); $this->assertEquals("custom_06", $custom[5]['customColumnType']['columnTitle']); $this->assertEquals("Not Set", $custom[5]['htmlvalue']); $this->assertEquals("custom_07", $custom[6]['customColumnType']['columnTitle']); $this->assertEquals("100000.0", $custom[6]['htmlvalue']); $this->assertEquals("custom_08", $custom[7]['customColumnType']['columnTitle']); $this->assertEquals("Not Set", $custom[7]['htmlvalue']); $this->assertEquals("custom_09", $custom[8]['customColumnType']['columnTitle']); $this->assertEquals("Not Set", $custom[8]['htmlvalue']); $this->assertEquals("custom_10", $custom[9]['customColumnType']['columnTitle']); $this->assertEquals("No", $custom[9]['htmlvalue']); $_SERVER["HTTP_USER_AGENT"] = ""; $_GET["custom"] = NULL; $config['cops_calibre_custom_column'] = array(); $config['cops_calibre_custom_column_list'] = array(); $config['cops_calibre_custom_column_preview'] = array(); $config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; Base::clearDb(); }