/** * Creates Service * * @param ServiceLocatorInterface $serviceLocator Zend Service Locator * * @return Page */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */ $entityManager = $serviceLocator->get('Doctrine\\ORM\\EntityManager'); /** @var \Rcm\Repository\Page $pageRepo */ $pageRepo = $entityManager->getRepository('\\Rcm\\Entity\\Page'); /** @var \Rcm\Entity\Site $currentSite */ $currentSite = $serviceLocator->get('Rcm\\Service\\CurrentSite'); $pageValidator = new Page($pageRepo); $pageValidator->setSiteId($currentSite->getSiteId()); return $pageValidator; }
/** * Test Is Valid Invalid when page name contains non english char * * @return void * * @covers \Rcm\Validator\PageName::isValid */ public function testIsValidWhenPageNameContainsNonEnglishChars() { $pageName = 'relìv'; $result = $this->validator->isValid($pageName); $this->assertFalse($result); $messages = $this->validator->getMessages(); $this->assertNotEmpty($messages); $errors = array_keys($messages); $this->assertEquals('pageName', $errors[0]); }
/** * Test Is Valid when page exists * * @return void * * @covers \Rcm\Validator\Page::isValid */ public function testIsValidWhenPageNameInvalid() { $pageName = 'test page'; $pageType = 'z'; $this->pageRepo->expects($this->never())->method('findOneBy'); $this->validator->setPageType($pageType); $result = $this->validator->isValid($pageName); $this->assertFalse($result); $messages = $this->validator->getMessages(); $this->assertNotEmpty($messages); $errors = array_keys($messages); $this->assertEquals('pageName', $errors[0]); }