public function testContentDraftOnFlush()
 {
     $content = new MockContent();
     $this->assertNull($content->getDraft());
     $this->assertNull(self::$contentManager->getDraft($content));
     self::$em->persist($content);
     self::$em->flush($content);
     $this->assertNotNull($content->getDraft());
     $this->assertNotNull(self::$contentManager->getDraft($content));
     // Should create draft for content's elements that is instanceof BackBee\ClassContent\AbstractClassContent
     foreach ($content->getData() as $element) {
         if ($element instanceof AbstractClassContent) {
             $this->assertNotNull(self::$contentManager->getDraft($element));
         }
     }
 }
 public function testDeleteOnLinkedKeywordAction()
 {
     /* access a class content and "keyword" it */
     $keyword = $this->createAKeyword('cms');
     /* create a class content */
     $classContent = new MockContent();
     $classContent->load();
     $this->em->persist($classContent);
     $this->em->flush($classContent);
     $keyword->addContent($classContent);
     $this->em->flush();
     $url = '/rest/2/keyword/' . $keyword->getUid();
     $response = $this->sendRequest(self::requestDelete($url, []));
     $this->assertTrue($response->isServerError(), sprintf('HTTP 500 expected, HTTP %s returned.', $response->getStatusCode()));
     $this->assertEquals('KEYWORD_IS_LINKED', json_decode($response->getContent(), true)['message']);
 }
 public function testOnPostCallWithRendermodeWithTextHtmlHeader()
 {
     $content = new MockContent();
     $content->mockedDefineParam('rendermode', ['type' => 'select', 'value' => []]);
     $listener = new ClassContentListener();
     $data = json_encode(self::$contentManager->jsonEncode($content, AbstractContent::JSON_CONCISE_FORMAT));
     $request = Request::create('test', "GET");
     $response = Response::create($data, 200, ['CONTENT_TYPE' => 'text/html']);
     $listener->onPostCall($this->createPostResponseEvent($response, $request));
     $responseContent = json_decode($response->getContent());
     $this->assertFalse(isset($responseContent->parameters->rendermode->options));
 }