/** * Test whether exception is thrown * Invoke method setCodeOfSpecialRegistries to change the special Registries * Trying retrieve of inextant special Registries had to throw an exception. */ public function testFindInexistantSpecialRegistry() { $expected = array(RegistryRepository::ADMINISTRATOR, RegistryRepository::COMMUNITY_MANAGER, RegistryRepository::FOUNDER, RegistryRepository::MODERATOR, RegistryRepository::OWNER, 'fooBar'); $this->invokeMethod($this->registryRepository, 'setCodeOfSpecialRegistries', array($expected)); $this->setExpectedException('Doctrine\\ORM\\EntityNotFoundException'); $this->registryRepository->findOneByCode('fooBar'); }
/** * Test retrieving Logs by code or registry. */ public function testGetLog() { $limit = 5; $registry = $this->registryRepository->findAdministratorRegistry(); $actuals = $this->logRepository->getLog($registry, $limit, 5); $this->assertTrue(is_array($actuals)); $this->assertCount($limit, $actuals); foreach ($actuals as $actual) { $this->assertInstanceOf('Jdr\\AppBundle\\Entity\\Log', $actual); $this->assertContains($registry, $actual->getRegistries()); } }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); //On chope un id de chaque entity static::$kernel = static::createKernel(); static::$kernel->boot(); $this->container = static::$kernel->getContainer(); $this->em = $this->container->get('doctrine.orm.entity_manager'); $this->bannedIpRepository = $this->em->getRepository('JdrAppBundle:IpBanned'); $this->userRepository = $this->em->getRepository('ApplicationSonataUserBundle:User'); $this->groupRepository = $this->em->getRepository('ApplicationSonataUserBundle:Group'); $this->personnageRepository = $this->em->getRepository('JdrAppBundle:Personnage'); $this->frameRepository = $this->em->getRepository('JdrPartenaireBundle:Frame'); $this->newsRepository = $this->em->getRepository('JdrPartenaireBundle:News'); $this->siteRepository = $this->em->getRepository('JdrPartenaireBundle:Site'); $this->logRepository = $this->em->getRepository('JdrAppBundle:Log'); $this->registryRepository = $this->em->getRepository('JdrAppBundle:Registry'); $this->bannedIpId = $this->bannedIpRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->userId = $this->userRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->groupId = $this->groupRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->personnageId = $this->personnageRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->frameId = $this->frameRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->newsId = $this->newsRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->siteId = $this->siteRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->logId = $this->logRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->registryId = $this->registryRepository->findOneBy(array(), array('id' => 'DESC'))->getId(); $this->routes = array('/admin/dashboard', '/admin/search', '/admin/sonata/user/user/list', '/admin/sonata/user/user/create', "/admin/sonata/user/user/{$this->userId}/edit", "/admin/sonata/user/user/{$this->userId}/show", "/admin/sonata/user/user/{$this->userId}/delete", '/admin/sonata/user/group/list', '/admin/sonata/user/group/create', "/admin/sonata/user/group/{$this->groupId}/edit", "/admin/sonata/user/group/{$this->groupId}/show", "/admin/sonata/user/group/{$this->groupId}/delete", '/admin/jdr/app/personnage/list', '/admin/jdr/app/personnage/create', "/admin/jdr/app/personnage/{$this->personnageId}/edit", "/admin/jdr/app/personnage/{$this->personnageId}/show", "/admin/jdr/app/personnage/{$this->personnageId}/delete", '/admin/jdr/partenaire/frame/list', '/admin/jdr/partenaire/frame/create', "/admin/jdr/partenaire/frame/{$this->frameId}/edit", "/admin/jdr/partenaire/frame/{$this->frameId}/show", "/admin/jdr/partenaire/frame/{$this->frameId}/delete", '/admin/jdr/partenaire/news/list', '/admin/jdr/partenaire/news/create', "/admin/jdr/partenaire/news/{$this->newsId}/edit", "/admin/jdr/partenaire/news/{$this->newsId}/show", "/admin/jdr/partenaire/news/{$this->newsId}/delete", '/admin/jdr/partenaire/site/list', '/admin/jdr/partenaire/site/create', "/admin/jdr/partenaire/site/{$this->siteId}/edit", "/admin/jdr/partenaire/site/{$this->siteId}/show", "/admin/jdr/partenaire/site/{$this->siteId}/delete", '/admin/jdr/app/log/list', '/admin/jdr/app/log/create', "/admin/jdr/app/log/{$this->logId}/edit", "/admin/jdr/app/log/{$this->logId}/show", "/admin/jdr/app/log/{$this->logId}/delete", '/admin/jdr/app/registry/list', '/admin/jdr/app/registry/create', "/admin/jdr/app/registry/{$this->registryId}/edit", "/admin/jdr/app/registry/{$this->registryId}/show", "/admin/jdr/app/registry/{$this->registryId}/delete", '/admin/jdr/app/ipbanned/list', '/admin/jdr/app/ipbanned/create', "/admin/jdr/app/ipbanned/{$this->bannedIpId}/edit", "/admin/jdr/app/ipbanned/{$this->bannedIpId}/show", "/admin/jdr/app/ipbanned/{$this->bannedIpId}/delete", '/admin/sonata/media/media/list', '/admin/sonata/media/media/create', '/admin/sonata/media/gallery/list', '/admin/sonata/media/gallery/create'); }