/**
  * @param string $expectedMeta
  * @param string $newMeta
  * @param string $nodeId
  *
  * @dataProvider provideMetaAndNodeId
  */
 public function testEditNode($expectedMeta, $newMeta, $nodeId)
 {
     $nodeDocument = $this->nodeRepository->findInLastVersion($nodeId, $this->language, $this->siteId);
     $url = '/admin/node/form/' . $this->siteId . '/' . $nodeDocument->getNodeId() . '/' . $this->language . '/' . $nodeDocument->getVersion();
     $crawler = $this->client->request('GET', $url);
     $formNode = $crawler->selectButton('Save')->form();
     $formNode['oo_node[metaDescription]'] = $newMeta;
     $crawler = $this->submitForm($formNode);
     $this->assertContains('alert alert-success', $this->client->getResponse()->getContent());
     $formNode = $crawler->selectButton('Save')->form();
     $this->assertSame($expectedMeta, $formNode['oo_node[metaDescription]']->getValue());
 }
 /**
  * Test update not granted
  */
 public function testUpdateNotGranted()
 {
     $this->markTestSkipped('To reactivate when API roles will be implemented');
     $this->username = '******';
     $this->password = '******';
     $this->logIn();
     $node = $this->nodeRepository->findInLastVersion('root', 'fr', '2');
     $this->client->request('POST', '/api/node/' . $node->getId() . '/update', array(), array(), array(), json_encode(array('status_id' => 'fakeStatus')));
     $this->assertSame(403, $this->client->getResponse()->getStatusCode());
 }
 /**
  * test new Node
  */
 public function testNewNodePageHome()
 {
     $this->markTestSkipped('To reactivate when API roles will be implemented');
     $crawler = $this->client->request('GET', '/admin/');
     $crawler = $this->client->request('GET', '/admin/node/new/fixture_page_community');
     $formNode = $crawler->selectButton('Save')->form();
     $nodeName = 'fixturetest' . time();
     $formNode['oo_node[name]'] = $nodeName;
     $formNode['oo_node[nodeTemplateSelection][nodeSource]'] = 'root';
     $formNode['oo_node[routePattern]'] = '/page-test' . time();
     $this->submitForm($formNode);
     $this->client->request('GET', '/api/node/' . $nodeName);
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
     $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type'));
     $node = json_decode($this->client->getResponse()->getContent());
     $nodeId = $node->id;
     $statusRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.status');
     $statuses = array();
     $statuses[0] = $statusRepository->findOneBy(array("name" => "draft"));
     $statuses[1] = $statusRepository->findOneBy(array("name" => "published"));
     $statuses[2] = $statusRepository->findOneBy(array("name" => "pending"));
     $this->assertEquals(1, count($this->redirectionRepository->findAll()));
     $routeDocumentCount = count($this->routeDocumentRepository->findAll());
     $this->changeNodeStatusWithRouteRedirectionTest($nodeId, $statuses[2], 1, $routeDocumentCount);
     $this->changeNodeStatusWithRouteRedirectionTest($nodeId, $statuses[1], 1, $routeDocumentCount + 2);
     $this->client->request('POST', '/api/node/' . $nodeName . '/new-version/1?language=' . $node->language, array());
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
     $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type'));
     $newNode = $this->nodeRepository->findInLastVersion($nodeName, $node->language, $this->siteId);
     $newNode->setRoutePattern('/page-test' . time());
     $this->documentManager->persist($newNode);
     $this->documentManager->flush($newNode);
     $this->changeNodeStatusWithRouteRedirectionTest($newNode->getId(), $statuses[2], 1, $routeDocumentCount + 2);
     $this->changeNodeStatusWithRouteRedirectionTest($newNode->getId(), $statuses[1], 3, $routeDocumentCount + 6);
     $this->changeNodeStatusWithRouteRedirectionTest($newNode->getId(), $statuses[0], 1, $routeDocumentCount + 2);
     $this->changeNodeStatusWithRouteRedirectionTest($nodeId, $statuses[0], 1, $routeDocumentCount);
     $this->client->request('DELETE', '/api/node/' . $nodeName . '/delete');
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
     $this->assertEquals(1, count($this->redirectionRepository->findAll()));
     $this->assertEquals($routeDocumentCount, count($this->routeDocumentRepository->findAll()));
 }
 /**
  * @return string
  */
 public function show()
 {
     $siteId = $this->currentSiteManager->getCurrentSiteId();
     $nodes = $this->nodeRepository->findLastVersionByType($siteId);
     return $this->render('OpenOrchestraBackofficeBundle:BackOffice:Include/NavigationPanel/Menu/Editorial/nodes.html.twig', array('nodes' => $nodes, 'nodeId404' => ReadNodeInterface::ERROR_404_NODE_ID, 'nodeId503' => ReadNodeInterface::ERROR_503_NODE_ID));
 }
 /**
  * @param int    $count
  * @param string $language
  */
 protected function assertNodeCount($count, $language)
 {
     $nodes = $this->nodeRepository->findByNodeAndLanguageAndSite(NodeInterface::ROOT_NODE_ID, $language, $this->siteId);
     $this->assertCount($count, $nodes);
 }