Merge git://github.com/seblucas/cops
Conflicts: test/pageTest.php - RESOLVED
This commit is contained in:
commit
f87963ea8a
|
@ -61,6 +61,12 @@ ExpiresByType text/javascript "access plus 1 year"
|
||||||
###########################################
|
###########################################
|
||||||
# Uncomment if you wish to protect access with a password
|
# Uncomment if you wish to protect access with a password
|
||||||
###########################################
|
###########################################
|
||||||
|
# If your covers and books are not available as soon as you protect it
|
||||||
|
# You can try replacing the FilesMatch directive by this one
|
||||||
|
# <FilesMatch "(index|feed)\.php">
|
||||||
|
# If helps for Sony PRS-TX and Aldiko, beware fetch.php can be accessed
|
||||||
|
# with authentication
|
||||||
|
###########################################
|
||||||
#<FilesMatch "\.php$">
|
#<FilesMatch "\.php$">
|
||||||
#AuthUserFile /path/to/file
|
#AuthUserFile /path/to/file
|
||||||
#AuthGroupFile /dev/null
|
#AuthGroupFile /dev/null
|
||||||
|
|
11
.travis.yml
11
.travis.yml
|
@ -10,4 +10,13 @@ script:
|
||||||
- phpunit
|
- phpunit
|
||||||
- jshint --verbose --show-non-errors util.js
|
- jshint --verbose --show-non-errors util.js
|
||||||
- php test/coverage-checker.php clover.xml 45
|
- php test/coverage-checker.php clover.xml 45
|
||||||
|
after_success:
|
||||||
|
- chmod +x test/prepareSauceTest.sh
|
||||||
|
- test/prepareSauceTest.sh
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- SAUCE_USERNAME=seblucas
|
||||||
|
- secure: VVxocvmz6WYr3tZSTA42M/LUhaHoBWw5onh85hnquoMaxspd3tDCyfQIowTTmEXikRh2T0CkTH7X3dhVwRTd/Ha9isja1qDo9Lc2flGCoWICF7WFZuom084+d+O+EWx4WZMAw4Lz4w6a5xflpPKnzNs9B0+de0BdTlQ5qSXVrcA=
|
||||||
|
addons:
|
||||||
|
hosts:
|
||||||
|
- cops-travis
|
||||||
|
|
|
@ -4,11 +4,14 @@
|
||||||
* Updated the way locales are handled. Should be easier to add new languages.
|
* Updated the way locales are handled. Should be easier to add new languages.
|
||||||
* Fixed display of Cyrillic characters.
|
* Fixed display of Cyrillic characters.
|
||||||
* Upgraded doT to version 1.0.1, Magnific-Popup to 0.9.8, Normalize.css to 2.1.3, Jquery-cookie to 1.4.0.
|
* Upgraded doT to version 1.0.1, Magnific-Popup to 0.9.8, Normalize.css to 2.1.3, Jquery-cookie to 1.4.0.
|
||||||
* Upgraded
|
|
||||||
* Fixed OPDS stream validity. Reported by Didier.
|
* Fixed OPDS stream validity. Reported by Didier.
|
||||||
* Added a new check in checkconfig.php to detect case problem between the actual path and the path stored in Calibre database. Try checkconfig.php?full=1. Reported by Ruud.
|
* Added a new check in checkconfig.php to detect case problem between the actual path and the path stored in Calibre database. Try checkconfig.php?full=1. Reported by Ruud.
|
||||||
* Fixed the display of the rating stars with Chrome. Thanks to At_Libitum.
|
* Fixed the display of the rating stars with Chrome. Thanks to At_Libitum.
|
||||||
* Added a new parameter to avoid splitting the books by first letter. Thanks to At_Libitum.
|
* Added a new parameter ($config['cops_titles_split_first_letter']) to avoid splitting the books by first letter. Thanks to At_Libitum.
|
||||||
|
* Fixed non compliant OPDS search (for Stanza, Moon+ Reader, ...). Reported by At_Libitum.
|
||||||
|
* Fixed the redirection in case the Calibre database is not found. Reported by At_Libitum
|
||||||
|
* Changed .htaccess to allow the use of password protected catalogs with Sony's eReader (PRS-TX). Thanks to Ruud for the beta testing.
|
||||||
|
* Updated Chinese, German, Norwegian, Portuguese, Russian translations. Thanks to all the translators.
|
||||||
|
|
||||||
0.6.2 - 20130913
|
0.6.2 - 20130913
|
||||||
* Added server side rendering for devices like PRS-TX / Kindle / Cybook. Thanks to all the testers.
|
* Added server side rendering for devices like PRS-TX / Kindle / Cybook. Thanks to all the testers.
|
||||||
|
|
|
@ -4,3 +4,9 @@ cops
|
||||||
Calibre OPDS (and HTML) PHP Server : light alternative to Calibre content server / Calibre2OPDS
|
Calibre OPDS (and HTML) PHP Server : light alternative to Calibre content server / Calibre2OPDS
|
||||||
|
|
||||||
See : http://blog.slucas.fr/en/oss/calibre-opds-php-server
|
See : http://blog.slucas.fr/en/oss/calibre-opds-php-server
|
||||||
|
|
||||||
|
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/seblucas/cops/badges/quality-score.png?s=e1c87a92ef90b8d666cd9bd4f3612bd10db84364)](https://scrutinizer-ci.com/g/seblucas/cops/)
|
||||||
|
|
||||||
|
[![Code Coverage](https://scrutinizer-ci.com/g/seblucas/cops/badges/coverage.png?s=1e21d8c3bf96d7b0b7cc0e54429fa897ddea1506)](https://scrutinizer-ci.com/g/seblucas/cops/)
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/seblucas/cops.png)](https://travis-ci.org/seblucas/cops)
|
||||||
|
|
39
base.php
39
base.php
|
@ -16,6 +16,13 @@ function useServerSideRendering () {
|
||||||
return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
|
return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQueryString () {
|
||||||
|
if ( isset($_SERVER['QUERY_STRING']) ) {
|
||||||
|
return $_SERVER['QUERY_STRING'];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function getURLParam ($name, $default = NULL) {
|
function getURLParam ($name, $default = NULL) {
|
||||||
if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
|
if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
|
||||||
return $_GET[$name];
|
return $_GET[$name];
|
||||||
|
@ -192,6 +199,9 @@ function localize($phrase, $count=-1, $reset=false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addURLParameter($urlParams, $paramName, $paramValue) {
|
function addURLParameter($urlParams, $paramName, $paramValue) {
|
||||||
|
if (empty ($urlParams)) {
|
||||||
|
$urlParams = "";
|
||||||
|
}
|
||||||
$start = "";
|
$start = "";
|
||||||
if (preg_match ("#^\?(.*)#", $urlParams, $matches)) {
|
if (preg_match ("#^\?(.*)#", $urlParams, $matches)) {
|
||||||
$start = "?";
|
$start = "?";
|
||||||
|
@ -487,8 +497,8 @@ class Page
|
||||||
|
|
||||||
public function getNextLink ()
|
public function getNextLink ()
|
||||||
{
|
{
|
||||||
$currentUrl = $_SERVER['QUERY_STRING'];
|
$currentUrl = getQueryString ();
|
||||||
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']);
|
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
|
||||||
if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
|
if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
|
||||||
return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
|
return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
|
||||||
}
|
}
|
||||||
|
@ -497,8 +507,8 @@ class Page
|
||||||
|
|
||||||
public function getPrevLink ()
|
public function getPrevLink ()
|
||||||
{
|
{
|
||||||
$currentUrl = $_SERVER['QUERY_STRING'];
|
$currentUrl = getQueryString ();
|
||||||
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . $_SERVER['QUERY_STRING']);
|
$currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
|
||||||
if ($this->n > 1) {
|
if ($this->n > 1) {
|
||||||
return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
|
return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
|
||||||
}
|
}
|
||||||
|
@ -795,7 +805,6 @@ class PageCustomize extends Page
|
||||||
{
|
{
|
||||||
public function InitializeContent ()
|
public function InitializeContent ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$this->title = localize ("customize.title");
|
$this->title = localize ("customize.title");
|
||||||
$this->entryArray = array ();
|
$this->entryArray = array ();
|
||||||
|
|
||||||
|
@ -927,15 +936,22 @@ abstract class Base
|
||||||
return self::getDbDirectory ($database) .'metadata.db';
|
return self::getDbDirectory ($database) .'metadata.db';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDb ($database = NULL) {
|
private static function error () {
|
||||||
global $config;
|
|
||||||
if (is_null (self::$db)) {
|
|
||||||
try {
|
|
||||||
self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
|
|
||||||
} catch (Exception $e) {
|
|
||||||
header("location: checkconfig.php?err=1");
|
header("location: checkconfig.php?err=1");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDb ($database = NULL) {
|
||||||
|
if (is_null (self::$db)) {
|
||||||
|
try {
|
||||||
|
if (is_readable (self::getDbFileName ($database))) {
|
||||||
|
self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
|
||||||
|
} else {
|
||||||
|
self::error ();
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
self::error ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self::$db;
|
return self::$db;
|
||||||
}
|
}
|
||||||
|
@ -945,7 +961,6 @@ abstract class Base
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
|
public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
|
||||||
global $config;
|
|
||||||
$totalResult = -1;
|
$totalResult = -1;
|
||||||
|
|
||||||
if (is_null ($numberPerPage)) {
|
if (is_null ($numberPerPage)) {
|
||||||
|
|
2
book.php
2
book.php
|
@ -452,7 +452,7 @@ class Book extends Base {
|
||||||
{
|
{
|
||||||
if ($data->isKnownType ())
|
if ($data->isKnownType ())
|
||||||
{
|
{
|
||||||
array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, "Download"));
|
array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, $data->format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ Please check
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</article>
|
</article>
|
||||||
|
<?php if (is_readable (Base::getDbFileName ($i))) { ?>
|
||||||
<article class="frontpage">
|
<article class="frontpage">
|
||||||
<h2>Check if Calibre database file can be opened with PHP</h2>
|
<h2>Check if Calibre database file can be opened with PHP</h2>
|
||||||
<h4>
|
<h4>
|
||||||
|
@ -182,6 +183,7 @@ Please check
|
||||||
</h4>
|
</h4>
|
||||||
</article>
|
</article>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php } ?>
|
||||||
<?php $i++; } ?>
|
<?php $i++; } ?>
|
||||||
</section>
|
</section>
|
||||||
<footer></footer>
|
<footer></footer>
|
||||||
|
|
21
index.php
21
index.php
|
@ -24,12 +24,27 @@
|
||||||
exit ();
|
exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
header ("Content-Type:text/html;charset=utf-8");
|
|
||||||
$page = getURLParam ("page", Base::PAGE_INDEX);
|
$page = getURLParam ("page", Base::PAGE_INDEX);
|
||||||
$query = getURLParam ("query");
|
$query = getURLParam ("query");
|
||||||
$qid = getURLParam ("id");
|
$qid = getURLParam ("id");
|
||||||
$n = getURLParam ("n", "1");
|
$n = getURLParam ("n", "1");
|
||||||
$database = GetUrlParam (DB);
|
$database = GetUrlParam (DB);
|
||||||
|
|
||||||
|
|
||||||
|
// Access the database ASAP to be sure it's readable, redirect if that's not the case.
|
||||||
|
// It has to be done before any header is sent.
|
||||||
|
if (is_array ($config['calibre_directory']) && is_null ($database)) {
|
||||||
|
$i = 0;
|
||||||
|
foreach (array_keys ($config['calibre_directory']) as $key) {
|
||||||
|
$test = Base::getDb ($i);
|
||||||
|
Base::clearDb ();
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$test = Base::getDb ();
|
||||||
|
}
|
||||||
|
|
||||||
|
header ("Content-Type:text/html;charset=utf-8");
|
||||||
?><!DOCTYPE html>
|
?><!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
|
@ -66,7 +81,7 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Handler for .ready() called.
|
// Handler for .ready() called.
|
||||||
|
|
||||||
var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
|
var url = "<?php echo "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1); ?>";
|
||||||
|
|
||||||
$.when($.get('templates/default/header.html'),
|
$.when($.get('templates/default/header.html'),
|
||||||
$.get('templates/default/footer.html'),
|
$.get('templates/default/footer.html'),
|
||||||
|
@ -98,7 +113,9 @@
|
||||||
|
|
||||||
updatePage (data [0]);
|
updatePage (data [0]);
|
||||||
cache.put (url, data [0]);
|
cache.put (url, data [0]);
|
||||||
|
if (isPushStateEnabled) {
|
||||||
history.replaceState(url, "", window.location);
|
history.replaceState(url, "", window.location);
|
||||||
|
}
|
||||||
handleLinks ();
|
handleLinks ();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,8 @@ class OpdsTest extends PHPUnit_Framework_TestCase
|
||||||
global $config;
|
global $config;
|
||||||
$page = Base::PAGE_INDEX;
|
$page = Base::PAGE_INDEX;
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$search = NULL;
|
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
$database = NULL;
|
|
||||||
|
|
||||||
$_SERVER['QUERY_STRING'] = "";
|
$_SERVER['QUERY_STRING'] = "";
|
||||||
$config['cops_subtitle_default'] = "My subtitle";
|
$config['cops_subtitle_default'] = "My subtitle";
|
||||||
|
@ -66,10 +64,8 @@ class OpdsTest extends PHPUnit_Framework_TestCase
|
||||||
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||||
$page = Base::PAGE_AUTHOR_DETAIL;
|
$page = Base::PAGE_AUTHOR_DETAIL;
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$search = NULL;
|
|
||||||
$qid = "1";
|
$qid = "1";
|
||||||
$n = "1";
|
$n = "1";
|
||||||
$database = NULL;
|
|
||||||
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1";
|
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1";
|
||||||
$_GET ["db"] = "0";
|
$_GET ["db"] = "0";
|
||||||
|
|
||||||
|
@ -87,10 +83,8 @@ class OpdsTest extends PHPUnit_Framework_TestCase
|
||||||
global $config;
|
global $config;
|
||||||
$page = Base::PAGE_AUTHOR_DETAIL;
|
$page = Base::PAGE_AUTHOR_DETAIL;
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$search = NULL;
|
|
||||||
$qid = "1";
|
$qid = "1";
|
||||||
$n = "1";
|
$n = "1";
|
||||||
$database = NULL;
|
|
||||||
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1";
|
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1";
|
||||||
|
|
||||||
$config['cops_max_item_per_page'] = 2;
|
$config['cops_max_item_per_page'] = 2;
|
||||||
|
|
140
test/Sauce.php
Normal file
140
test/Sauce.php
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
|
class Cops extends Sauce\Sausage\WebDriverTestCase
|
||||||
|
{
|
||||||
|
public static $browsers = array(
|
||||||
|
// run FF15 on Windows 8 on Sauce
|
||||||
|
array(
|
||||||
|
'browserName' => 'firefox',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'version' => '15',
|
||||||
|
'platform' => 'Windows 2012',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// run IE9 on Windows 7 on Sauce
|
||||||
|
array(
|
||||||
|
'browserName' => 'internet explorer',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'version' => '9',
|
||||||
|
'platform' => 'Windows 7',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// run IE10 on Windows 8 on Sauce
|
||||||
|
array(
|
||||||
|
'browserName' => 'internet explorer',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'version' => '10',
|
||||||
|
'platform' => 'Windows 8',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// run Opera 12 on Windows 7 on Sauce
|
||||||
|
array(
|
||||||
|
'browserName' => 'opera',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'version' => '12',
|
||||||
|
'platform' => 'Windows 7',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// run Mobile Safari on iOS
|
||||||
|
array(
|
||||||
|
'browserName' => '',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'app' => 'safari',
|
||||||
|
'device' => 'iPhone Simulator',
|
||||||
|
'version' => '6.1',
|
||||||
|
'platform' => 'Mac 10.8',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// run Chrome on Linux on Sauce
|
||||||
|
array(
|
||||||
|
'browserName' => 'chrome',
|
||||||
|
'desiredCapabilities' => array(
|
||||||
|
'version' => '30',
|
||||||
|
'platform' => 'Linux'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// run Mobile Browser on Android
|
||||||
|
// array(
|
||||||
|
// 'browserName' => 'Android',
|
||||||
|
// 'desiredCapabilities' => array(
|
||||||
|
// 'version' => '4.0',
|
||||||
|
// 'platform' => 'Linux',
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
|
||||||
|
// run Chrome locally
|
||||||
|
//array(
|
||||||
|
//'browserName' => 'chrome',
|
||||||
|
//'local' => true,
|
||||||
|
//'sessionStrategy' => 'shared'
|
||||||
|
//)
|
||||||
|
);
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
if (isset ($_SERVER["TRAVIS_JOB_NUMBER"])) {
|
||||||
|
$caps = $this->getDesiredCapabilities();
|
||||||
|
$caps['build'] = getenv ("TRAVIS_JOB_NUMBER");
|
||||||
|
$this->setDesiredCapabilities($caps);
|
||||||
|
}
|
||||||
|
parent::setUp ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpPage()
|
||||||
|
{
|
||||||
|
if (isset ($_SERVER["TRAVIS_JOB_NUMBER"])) {
|
||||||
|
$this->url('http://127.0.0.1:8888/index.php');
|
||||||
|
} else {
|
||||||
|
$this->url('http://cops-demo.slucas.fr/index.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
$driver = $this;
|
||||||
|
$title_test = function($value) use ($driver) {
|
||||||
|
$text = $driver->byXPath('//h1')->text ();
|
||||||
|
return $text == $value;
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->spinAssert("Home Title", $title_test, [ "COPS DEMO" ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function string_to_ascii($string)
|
||||||
|
{
|
||||||
|
$ascii = NULL;
|
||||||
|
|
||||||
|
for ($i = 0; $i < strlen($string); $i++)
|
||||||
|
{
|
||||||
|
$ascii += ord($string[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mb_detect_encoding($string) . "X" . $ascii;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTitle()
|
||||||
|
{
|
||||||
|
$driver = $this;
|
||||||
|
$title_test = function($value) use ($driver) {
|
||||||
|
$text = $driver->byXPath('//h1')->text ();
|
||||||
|
return $text == $value;
|
||||||
|
};
|
||||||
|
|
||||||
|
$author = $this->byXPath ('//h2[contains(text(), "Authors")]');
|
||||||
|
$author->click ();
|
||||||
|
|
||||||
|
$this->spinAssert("Author Title", $title_test, [ "AUTHORS" ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCog()
|
||||||
|
{
|
||||||
|
$cog = $this->byId ("searchImage");
|
||||||
|
|
||||||
|
$search = $this->byName ("query");
|
||||||
|
$this->assertFalse ($search->displayed ());
|
||||||
|
|
||||||
|
$cog->click ();
|
||||||
|
|
||||||
|
$search = $this->byName ("query");
|
||||||
|
$this->assertTrue ($search->displayed ());
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,4 +42,19 @@ class BaseTest extends PHPUnit_Framework_TestCase
|
||||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
|
||||||
localize ("authors.title", -1, true);
|
localize ("authors.title", -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBaseFunction () {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$this->assertFalse (Base::isMultipleDatabaseEnabled ());
|
||||||
|
$this->assertEquals (array ("" => dirname(__FILE__) . "/BaseWithSomeBooks/"), Base::getDbList ());
|
||||||
|
|
||||||
|
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||||
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||||
|
|
||||||
|
$this->assertTrue (Base::isMultipleDatabaseEnabled ());
|
||||||
|
$this->assertEquals ("Some books", Base::getDbName (0));
|
||||||
|
$this->assertEquals ("One book", Base::getDbName (1));
|
||||||
|
$this->assertEquals ($config['calibre_directory'], Base::getDbList ());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -118,6 +118,7 @@ class BookTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
// All books by first letter
|
// All books by first letter
|
||||||
list ($entryArray, $totalNumber) = Book::getBooksByStartingLetter ("T", -1);
|
list ($entryArray, $totalNumber) = Book::getBooksByStartingLetter ("T", -1);
|
||||||
|
$this->assertEquals (-1, $totalNumber);
|
||||||
$this->assertCount (3, $entryArray);
|
$this->assertCount (3, $entryArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,4 +201,30 @@ class BookTest extends PHPUnit_Framework_TestCase
|
||||||
$_GET["search"] = NULL;
|
$_GET["search"] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTypeaheadSearchMultiDatabase ()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
$_GET["query"] = "art";
|
||||||
|
$_GET["search"] = "1";
|
||||||
|
$_GET["multi"] = "1";
|
||||||
|
|
||||||
|
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||||
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||||
|
|
||||||
|
$array = getJson ();
|
||||||
|
|
||||||
|
$this->assertCount (4, $array);
|
||||||
|
$this->assertEquals ("Some books", $array[0]["title"]);
|
||||||
|
$this->assertEquals ("No book", $array[1]["title"]);
|
||||||
|
$this->assertEquals ("One book", $array[2]["title"]);
|
||||||
|
$this->assertEquals ("1 book", $array[3]["title"]);
|
||||||
|
|
||||||
|
$_GET["query"] = NULL;
|
||||||
|
$_GET["search"] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown () {
|
||||||
|
Base::clearDb ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
17
test/config_local.php.sauce
Normal file
17
test/config_local.php.sauce
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
if (!isset($config))
|
||||||
|
$config = array();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The directory containing calibre's metadata.db file, with sub-directories
|
||||||
|
* containing all the formats.
|
||||||
|
* BEWARE : it has to end with a /
|
||||||
|
*/
|
||||||
|
$config['calibre_directory'] = './test/BaseWithSomeBooks/';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Catalog's title
|
||||||
|
*/
|
||||||
|
$config['cops_title_default'] = "COPS DEMO";
|
||||||
|
|
||||||
|
// $config['cops_server_side_render'] = ".";
|
|
@ -18,10 +18,8 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
||||||
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||||
$page = Base::PAGE_INDEX;
|
$page = Base::PAGE_INDEX;
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$search = NULL;
|
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
$database = NULL;
|
|
||||||
|
|
||||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
$currentPage->InitializeContent ();
|
$currentPage->InitializeContent ();
|
||||||
|
@ -34,4 +32,31 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||||
$this->assertFalse ($currentPage->ContainsBook ());
|
$this->assertFalse ($currentPage->ContainsBook ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPageSearchXXX ()
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||||
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||||
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||||
|
$query = "art";
|
||||||
|
$qid = NULL;
|
||||||
|
$n = "1";
|
||||||
|
|
||||||
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
|
$currentPage->InitializeContent ();
|
||||||
|
|
||||||
|
$this->assertEquals ("Search result for *art*", $currentPage->title);
|
||||||
|
$this->assertCount (2, $currentPage->entryArray);
|
||||||
|
$this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
|
||||||
|
$this->assertEquals ("10 books", $currentPage->entryArray [0]->content);
|
||||||
|
$this->assertEquals ("One book", $currentPage->entryArray [1]->title);
|
||||||
|
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||||
|
$this->assertFalse ($currentPage->ContainsBook ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tearDownAfterClass () {
|
||||||
|
Base::clearDb ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -329,7 +329,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$qid = "1";
|
$qid = "1";
|
||||||
$n = "1";
|
$n = "1";
|
||||||
|
|
||||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
$currentPage->InitializeContent ();
|
$currentPage->InitializeContent ();
|
||||||
|
|
||||||
|
@ -374,7 +373,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPageAllTags ()
|
public function testPageAllTags ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$page = Base::PAGE_ALL_TAGS;
|
$page = Base::PAGE_ALL_TAGS;
|
||||||
$query = NULL;
|
$query = NULL;
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
|
@ -522,7 +520,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPageSearchScopeAuthors ()
|
public function testPageSearchScopeAuthors ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
|
@ -543,7 +540,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPageSearchScopeSeries ()
|
public function testPageSearchScopeSeries ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
|
@ -564,7 +560,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPageSearchScopeBooks ()
|
public function testPageSearchScopeBooks ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
|
@ -584,7 +579,6 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testPageSearchScopePublishers ()
|
public function testPageSearchScopePublishers ()
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||||
$qid = NULL;
|
$qid = NULL;
|
||||||
$n = "1";
|
$n = "1";
|
||||||
|
|
27
test/prepareSauceTest.sh
Normal file
27
test/prepareSauceTest.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ -z $SAUCE_ACCESS_KEY ]]
|
||||||
|
then
|
||||||
|
echo "No Sauce Api Key (Pull request)"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
PHP_VERSION=`php -v|grep --only-matching --perl-regexp "PHP 5\.\\d+"`
|
||||||
|
echo $PHP_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $PHP_VERSION != "PHP 5.4" ]]
|
||||||
|
then
|
||||||
|
echo "Bad PHP version"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Good PHP version"
|
||||||
|
|
||||||
|
curl https://gist.github.com/seblucas/7692094/raw/e2a090e6ea639a0d700e6d02cee048fa2f6c8617/sauce_connect_setup.sh | bash
|
||||||
|
curl -s https://raw.github.com/jlipps/sausage-bun/master/givememysausage.php | php
|
||||||
|
cp -v test/config_local.php.sauce config_local.php
|
||||||
|
php -S 127.0.0.1:8888 &
|
||||||
|
vendor/bin/phpunit --no-configuration test/Sauce.php
|
||||||
|
|
||||||
|
|
4
util.js
4
util.js
|
@ -281,7 +281,11 @@ updatePage = function (data) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$('input[name=query]').bind('typeahead:selected', function(obj, datum) {
|
$('input[name=query]').bind('typeahead:selected', function(obj, datum) {
|
||||||
|
if (isPushStateEnabled) {
|
||||||
navigateTo (datum.navlink);
|
navigateTo (datum.navlink);
|
||||||
|
} else {
|
||||||
|
window.location = datum.navlink;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue