From d4f18867435fc2f8a7f8d9a5a18a3b855cd258cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Sun, 20 Oct 2013 22:26:14 +0200 Subject: [PATCH 1/3] Add some new test for custom columns (and update the test database). re #96 --- test/metadata.db | Bin 139264 -> 192512 bytes test/pageTest.php | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/test/metadata.db b/test/metadata.db index 6bab9228b377fa0905d958e472bf490a2b212986..9a742ef7b2d53d97b5cbde89bfd672865312f3b7 100644 GIT binary patch delta 24159 zcmc&+3v?XSd7e9WwOUD*^|Btu*j}%Rv5+kGA={FBOc6pD;s-BtoJZ+;tzFw&OIooH zV;jtPIR+8}6thXTDJ_LGEhPzHV?aRc!^6#i_5=zk3ED(m|5trS{f&A|J*vK{zNEgOK6h||=Q}8; zse>Afd^p<<*N3ugaD6b_3fCWJXTkMH*%r9|Q??PV-_O>;^}cK^T<^`+!1W)p9=P6< zt%mF0XWekkXE9vAeFI!_yWw)z^>EpD9bE3*1((}*!X=r3%QfS086Sm9;@|*2GHaFx zU!dSm@NxVz{9~NQ*Wyk10wD1mtj+V_0kkQR*p>zA1?m?�Rt{ZsEK@@kI+o=*@sXK`Sc@HOFkDPq>@iBLYRDZAmk#SjR?&k zpD<57B0_Ok?g_fwB_3Ff^tu>UBf>i$RwLr;gVl%t{jeGl;bK^g=#&>$1Nvb(7a~G! zgw<5|^c?(rwWqrlPINOb37JUPcG@$jA{Cn8?t9V`wZf7)M{#Q`tfAykA_MBdh>K=LG z6h?IiPyYnFI(8^E%4!Aw4}K9(;JekwmDTD#yhM31x4;w7x|&_eXvk!W}{mX1KL$aS?|uaEFzYzyp; ze1q?>-(i?xOCq@wZl;r&Shv?`NsTi;XsKBDuj|{~FzZjXX`2-$)z?bJBFW*c;dCrH zN;v;@N`XObtww0Qn)e2pM>8Yo`1nYSY-BgTpN?#zcl1rBe7pe$#G-NDEN^mKd@Krc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JgLf|d}f^}&|AHJuc#16BgMZJWL*{DA+F3aV+tgziISw^euB6OlUDM4>mpjH WSYbp82{tBe7da4O&tqOPfkcka+q-O!XWvQ=*-)$bJnApX6hote>Y`JMM9r5(*M_rmD&J*5_968zU_-cMXO z5EGjR_Ls8wZIcYRLU5&|@B1A~D_fHfZc%Z9;B~x)mvIRfa28MF6i(nVafIWb0?-Ju zDiHu3WF^D|$ng+WkmV3HkYgcIkfjh2WDHRPnTA*oGKAOwn&=~vTM$y0h0v^!y&lO; zL~^?op{B(p2-VaG6QD$>LOepD79oXLga}fE5@3Y&Ktn9ucueX1NMcG!8v5G>{qu=+ z1if_Y3zV7&iPLd{zufSbW1G01#R#@EH{+FvdC<%Q4mfV}z0ugq)zqVN7)MDL*p@XZV|Qu+u*}T*vQI=??w2n&swfGi|yi ze|#Rg_}ePo-sQGK*0tSUv#&Sh_AxtU*@m4eIK}={Fbv3jCyRB=sztuiS*C+6+s3hQqI{!&+^|NIRYvtlk1mX@I|k z?-jt!q(Umf_wy=jCVTe0uIkC)nnLdeewRj{+~JCn|2nLCXr&CJ*~sL?V%0n!oQJk> z9IahWI~4mp$18YF%FftE%IYt&RByq{rX0h}*u7TKELiTpassertFalse ($currentPage->ContainsBook ()); } + public function testPageIndexWithCustomColumn () + { + global $config; + $page = Base::PAGE_INDEX; + $query = NULL; + $search = NULL; + $qid = NULL; + $n = "1"; + $database = NULL; + + $config['cops_calibre_custom_column'] = array ("type1"); + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertCount (7, $currentPage->entryArray); + $this->assertEquals ("Type1", $currentPage->entryArray [4]->title); + $this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [4]->content); + + $config['cops_calibre_custom_column'] = array ("type2"); + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertCount (7, $currentPage->entryArray); + $this->assertEquals ("Type2", $currentPage->entryArray [4]->title); + $this->assertEquals ("Alphabetical index of the 3 tags", $currentPage->entryArray [4]->content); + + $config['cops_calibre_custom_column'] = array ("type4"); + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertCount (7, $currentPage->entryArray); + $this->assertEquals ("Type4", $currentPage->entryArray [4]->title); + $this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [4]->content); + + $config['cops_calibre_custom_column'] = array ("type1", "type2", "type4"); + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertCount (9, $currentPage->entryArray); + + $config['cops_calibre_custom_column'] = array (); + } + public function testPageAllAuthors () { global $config; From ccd0e0b1a9a47c3cf893f0901727b9030e1858bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 22 Oct 2013 10:24:13 +0200 Subject: [PATCH 2/3] New tests. re #96 --- test/pageTest.php | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/pageTest.php b/test/pageTest.php index cde2441..6fdf2a6 100644 --- a/test/pageTest.php +++ b/test/pageTest.php @@ -82,6 +82,73 @@ class PageTest extends PHPUnit_Framework_TestCase $config['cops_calibre_custom_column'] = array (); } + public function testPageAllCustom () + { + global $config; + $page = Base::PAGE_ALL_CUSTOMS; + $query = NULL; + $search = NULL; + $qid = NULL; + $n = "1"; + $database = NULL; + + $_GET ["custom"] = "1"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("Type4", $currentPage->title); + $this->assertCount (2, $currentPage->entryArray); + $this->assertEquals ("SeriesLike", $currentPage->entryArray [0]->title); + $this->assertFalse ($currentPage->ContainsBook ()); + + $_GET ["custom"] = "2"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("Type2", $currentPage->title); + $this->assertCount (3, $currentPage->entryArray); + $this->assertEquals ("tag1", $currentPage->entryArray [0]->title); + $this->assertFalse ($currentPage->ContainsBook ()); + + $_GET ["custom"] = "3"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("Type1", $currentPage->title); + $this->assertCount (2, $currentPage->entryArray); + $this->assertEquals ("other", $currentPage->entryArray [0]->title); + $this->assertFalse ($currentPage->ContainsBook ()); + + $_GET ["custom"] = NULL; + } + + public function testPageCustomDetail () + { + global $config; + $page = Base::PAGE_CUSTOM_DETAIL; + $query = NULL; + $search = NULL; + $qid = "1"; + $n = "1"; + $database = NULL; + + $_GET ["custom"] = "1"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("SeriesLike", $currentPage->title); + $this->assertCount (2, $currentPage->entryArray); + $this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title); + $this->assertTrue ($currentPage->ContainsBook ()); + + + $_GET ["custom"] = NULL; + } + public function testPageAllAuthors () { global $config; From aca14938ca49e8a80e1487fde77501f8ab269fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 22 Oct 2013 10:32:22 +0200 Subject: [PATCH 3/3] New tests again for custom columns. re #96 --- test/pageTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/pageTest.php b/test/pageTest.php index 6fdf2a6..3a0d4a0 100644 --- a/test/pageTest.php +++ b/test/pageTest.php @@ -145,6 +145,26 @@ class PageTest extends PHPUnit_Framework_TestCase $this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title); $this->assertTrue ($currentPage->ContainsBook ()); + $_GET ["custom"] = "2"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("tag1", $currentPage->title); + $this->assertCount (2, $currentPage->entryArray); + $this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title); + $this->assertTrue ($currentPage->ContainsBook ()); + + $_GET ["custom"] = "3"; + $qid = "2"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $this->assertEquals ("other", $currentPage->title); + $this->assertCount (1, $currentPage->entryArray); + $this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [0]->title); + $this->assertTrue ($currentPage->ContainsBook ()); $_GET ["custom"] = NULL; }