From 800db3be4e74922f97f7564bb4e9d9de46be5ff9 Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@sandbox.pergame.net> Date: Thu, 4 Dec 2014 09:27:31 +0100 Subject: [PATCH] rel #17990 : fix tests fixture to reflect real usage case --- .../Class/CompositeBuilderTreeTest.php | 11 ++++----- .../Class/CompositeBuilderTreeTestCase.php | 24 ++++++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/library/Class/CompositeBuilderTreeTest.php b/tests/library/Class/CompositeBuilderTreeTest.php index 29698c11b10..35eff640c2f 100644 --- a/tests/library/Class/CompositeBuilderTreeTest.php +++ b/tests/library/Class/CompositeBuilderTreeTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class CompositeBuilderTreeTest extends CompositeBuilderTreeTestCase { @@ -25,7 +25,7 @@ class CompositeBuilderTreeTest extends CompositeBuilderTreeTestCase { } public function testFeteInternetIsInEvenements() { - $this->assertTrue(in_array($this->fete_internet, + $this->assertTrue(in_array($this->fete_internet, $this->evenements->getItems())); } @@ -33,7 +33,7 @@ class CompositeBuilderTreeTest extends CompositeBuilderTreeTestCase { $this->assertEquals(4, $this->visite_bib->getId()); } - public function testAnimationSubcategories() { + public function testAnimationSubcategories() { $this->assertEquals(array($this->animation_jeunesse, $this->animation_adulte), $this->animation->getCategories()); } @@ -77,7 +77,4 @@ class ItemVisitorTest extends CompositeBuilderTreeTestCase { $this->root->acceptVisitor($this); $this->assertEquals($this->expected_visit, $this->actual_visit); } -} - - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/library/Class/CompositeBuilderTreeTestCase.php b/tests/library/Class/CompositeBuilderTreeTestCase.php index 2540350a492..97216c0f1d8 100644 --- a/tests/library/Class/CompositeBuilderTreeTestCase.php +++ b/tests/library/Class/CompositeBuilderTreeTestCase.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with AFI-OPAC 2.0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ abstract class CompositeBuilderTreeTestCase extends PHPUnit_Framework_TestCase { public function setUp() { @@ -34,11 +34,18 @@ abstract class CompositeBuilderTreeTestCase extends PHPUnit_Framework_TestCase { - fete internet 5 */ $builder = new CompositeBuilder("ItemCategory", "BaseItem"); - $this->root = $builder->getRoot(); - $this->animation = $builder->newSubcategoryIn(1, 0); - $this->animation_jeunesse = $builder->newSubcategoryIn(11, 1); - $this->animation_adulte = $builder->newSubcategoryIn(12, 1); - $this->evenements = $builder->newSubCategoryIn(2, 0); + $this->root = $builder + ->getRoot() + ->addCategoriesFromRows([$this->def(1, 0), + $this->def(11, 1), + $this->def(12, 1), + $this->def(2, 0)], + 'id', 'pid'); + + $this->animation = $this->root->getCategoryWithId(1); + $this->animation_jeunesse = $this->animation->getCategoryWithId(11); + $this->animation_adulte = $this->animation->getCategoryWithId(12); + $this->evenements = $this->root->getCategoryWithId(2); $this->rencontre_pere_noel = $builder->newItemIn(2, 11); $this->carnaval = $builder->newItemIn(3, 11); @@ -48,5 +55,10 @@ abstract class CompositeBuilderTreeTestCase extends PHPUnit_Framework_TestCase { $this->categorie_fantome = $builder->newSubcategoryIn(99, 99); $this->article_fantome = $builder->newItemIn(99, 99); } + + + protected function def($id, $pid) { + return ['id' => $id, 'pid' => $pid]; + } } ?> \ No newline at end of file -- GitLab