category = new WikiCategory(); } /** * @testdox The model can be created and read from the database * @covers Modules\Knowledgebase\Models\WikiCategoryMapper * @group module */ public function testCR() : void { $this->category->setL11n('Test Category'); $id = WikiCategoryMapper::create()->execute($this->category); self::assertGreaterThan(0, $this->category->id); self::assertEquals($id, $this->category->id); $categoryR = WikiCategoryMapper::get()->with('name')->where('id', $this->category->id)->where('name/language', ISO639x1Enum::_EN)->execute(); self::assertEquals($this->category->getL11n(), $categoryR->getL11n()); self::assertGreaterThan(0, \count(WikiCategoryMapper::getAll()->where('app', 1)->execute())); } /** * @testdox The model can be created and read from the database with a parent category * @covers Modules\Knowledgebase\Models\WikiCategoryMapper * @group module */ public function testChildCR() : void { $this->category->app = new NullWikiApp(1); $this->category->setL11n('Test Category2'); $this->category->parent = new NullWikiCategory(1); $id = WikiCategoryMapper::create()->execute($this->category); self::assertGreaterThan(0, $this->category->id); self::assertEquals($id, $this->category->id); $categoryR = WikiCategoryMapper::get() ->with('name') ->where('id', $this->category->id) ->where('name/language', ISO639x1Enum::_EN) ->execute(); self::assertEquals($this->category->getL11n(), $categoryR->getL11n()); self::assertEquals($this->category->parent->id, $categoryR->parent->id); self::assertGreaterThan(0, \count( WikiCategoryMapper::getAll() ->with('name') ->where('parent', 1) ->where('app', 1) ->where('name/language', ISO639x1Enum::_EN) ->execute() ) ); } }