/** * tests the text */ public function testText() { $text = 'Lorem Ipsum'; $this->textnode->setText($text); $this->assertEquals($text, $this->textnode->getText()); }
private function createTextnodes(ManagerRegistry $mongo, DocumentManager $dm) { $loremIpsumLength = 3500; $repository = $mongo->getRepository('DembeloMain:Textnode'); $allAccessNodes = $repository->findByAccess(true); if (count($allAccessNodes) >= 7) { return; } $loremIpsum = $this->getContainer()->get('apoutchika.lorem_ipsum'); $textnodeData = array(array('topic' => $this->dummyData['topics'][0], 'text' => $loremIpsum->getWords($loremIpsumLength), 'access' => true, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 1', 'Autor' => 'Autor 1', 'Verlag' => 'Verlag 1')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 2', 'Autor' => 'Autor 2', 'Verlag' => 'Verlag 2')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 3', 'Autor' => 'Autor 3', 'Verlag' => 'Verlag 3')), array('topic' => $this->dummyData['topics'][1], 'text' => $loremIpsum->getWords($loremIpsumLength), 'access' => true, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 4', 'Autor' => 'Autor 4', 'Verlag' => 'Verlag 4')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 5', 'Autor' => 'Autor 5', 'Verlag' => 'Verlag 5')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 6', 'Autor' => 'Autor 6', 'Verlag' => 'Verlag 6'))); foreach ($textnodeData as $textnodeDatum) { $textnode = new Textnode(); $textnode->setStatus(Textnode::STATUS_ACTIVE); if (isset($textnodeDatum['topic'])) { $textnode->setTopicId($textnodeDatum['topic']->getId()); } if (isset($textnodeDatum['licensee'])) { $textnode->setLicenseeId($textnodeDatum['licensee']->getId()); } $textnode->setCreated(date('Y-m-d H:i:s')); $textnode->setText($textnodeDatum['text']); $textnode->setAccess($textnodeDatum['access']); $textnode->setMetadata($textnodeDatum['metadata']); $dm->persist($textnode); $this->dummyData['textnodes'][] = $textnode; } }
/** * Tests the action of reading a textnode without an active * user session. */ public function testReadTextnodeWithoutLogin() { $container = $this->getMock("Symfony\\Component\\DependencyInjection\\ContainerInterface"); $mongo = $this->getMockBuilder("Doctrine\\Bundle\\MongoDBBundle\\ManagerRegistry")->disableOriginalConstructor()->getMock(); $repository = $this->getMockBuilder("Doctrine\\ODM\\MongoDB\\DocumentRepository")->disableOriginalConstructor()->getMock(); $authorizationChecker = $this->getMockBuilder('foobar')->setMethods(array('isGranted'))->getMock(); $tokenStorage = $this->getMockBuilder("Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorage")->disableOriginalConstructor()->getMock(); $template = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface'); $container->expects($this->at(0))->method("get")->with($this->equalTo('doctrine_mongodb'))->will($this->returnValue($mongo)); $mongo->expects($this->once())->method("getRepository")->with($this->equalTo('DembeloMain:Textnode'))->will($this->returnValue($repository)); $hitch = array(); $hitch['textnodeId'] = "55f5ab3708985c4b188b4578"; $hitch['description'] = "Continue."; $hitch['status'] = Textnode::HITCH_STATUS_ACTIVE; $textnodeId = "55f5ab3708985c4b188b4577"; $textnode = new Textnode(); $textnode->setId($textnodeId); $textnode->setStatus(Textnode::STATUS_ACTIVE); $textnode->setText("Lorem ipsum dolor sit amet."); $textnode->appendHitch($hitch); $repository->expects($this->once())->method("findBy")->with(array('id' => new \MongoId($textnodeId), 'status' => Textnode::STATUS_ACTIVE))->will($this->returnValue(array($textnode))); $container->expects($this->at(1))->method("get")->with($this->equalTo('security.authorization_checker'))->will($this->returnValue($authorizationChecker)); $container->expects($this->at(2))->method("get")->with($this->equalTo('security.token_storage'))->will($this->returnValue($tokenStorage)); $authorizationChecker->expects($this->once())->method('isGranted')->with($this->equalTo('ROLE_USER'))->will($this->returnValue(false)); $container->expects($this->at(3))->method("get")->with("templating")->will($this->returnValue($template)); $template->expects($this->once())->method("renderResponse")->with("default/read.html.twig", array("textnode" => $textnode))->will($this->returnValue('renderresponse')); $controller = new DefaultController(); $controller->setContainer($container); $result = $controller->readTextnodeAction($textnodeId); $this->assertEquals('renderresponse', $result); }