function test_article() { $article = new Article(9000001,9000002,9000003,9000004); // Test create $article->create("Unit Test Long Name", "Unit Test Short Name", "fastnews"); $this->assertTrue($article->exists()); // Test SET functions $article->setTitle("Unit Test New Title"); $article->setCreatorId(9000005); $article->setOnFrontPage(true); $article->setOnSection(true); $article->setWorkflowStatus('Y'); $article->setKeywords("Unit, Test"); $article->setIsIndexed(true); // Test GET functions $articleCopy = new Article(9000001, 9000002, 9000003, 9000004, $article->getArticleId()); $this->assertEquals(9000001, $articleCopy->getPublicationId()); $this->assertEquals(9000002, $articleCopy->getIssueNumber()); $this->assertEquals(9000003, $articleCopy->getSectionNumber()); $this->assertEquals(9000004, $articleCopy->getLanguageId()); $this->assertEquals(9000005, $articleCopy->getCreatorId()); $this->assertEquals("Unit Test New Title", $articleCopy->getTitle()); $this->assertEquals(true, $articleCopy->onFrontPage()); $this->assertEquals(true, $articleCopy->onSection()); $this->assertEquals('Y', $articleCopy->getWorkflowStatus()); $this->assertEquals("Unit, Test", $articleCopy->getKeywords()); $this->assertEquals(true, $articleCopy->isIndexed()); // Test DELETE functions $article->delete(); $this->assertFalse($article->exists()); }
$author_type = $f_article_author_type[$i]; $authorObj->setType($author_type); // Links the author to the article if ($authorObj->getId() != 0) { $articleAuthorObj = new ArticleAuthor($articleObj->getArticleNumber(), $articleObj->getLanguageId(), $authorObj->getId(), $author_type, $i + 1); } if (isset($articleAuthorObj) && !$articleAuthorObj->exists()) { $articleAuthorObj->create(); $dispatcher->dispatch("user.set_points", new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('authorId' => $articleAuthorObj->getAuthorId()))); } $i++; } } // Update the article. $articleObj->setTitle($f_article_title); $articleObj->setIsIndexed(false); if (!empty($f_comment_status)) { if ($f_comment_status == "enabled" || $f_comment_status == "locked") { $commentsEnabled = true; } else { $commentsEnabled = false; } // If status has changed, then you need to show/hide all the comments // as appropriate. if ($articleObj->commentsEnabled() != $commentsEnabled) { $articleObj->setCommentsEnabled($commentsEnabled); global $controller; $repository = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment'); $repository->setArticleStatus($f_article_number, $f_language_selected, $commentsEnabled ? STATUS_APPROVED : STATUS_HIDDEN); $repository->flush(); }