6ed0cbc3428a27a5bd13f8d1cd4e62bb9b83a3ba
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\data\article\Article;
4 use wcf\data\article\ArticleAction;
5 use wcf\data\category\Category;
6 use wcf\data\user\UserProfile;
7
8 /**
9 * Provides a method to create a article for testing user notification
10 * events.
11 *
12 * @author Joshua Ruesweg
13 * @copyright 2001-2018 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\User\Notification\Event
16 * @since 5.2
17 */
18 trait TTestableArticleUserNotificationEvent {
19 /**
20 * Creates an test article.
21 *
22 * @param Category $category
23 * @param UserProfile $author
24 * @return Article
25 */
26 public static function getTestArticle(Category $category, UserProfile $author) {
27 /** @var Article $article */
28 $article = (new ArticleAction([], 'create', [
29 'data' => [
30 'time' => TIME_NOW,
31 'categoryID' => $category->categoryID,
32 'publicationStatus' => Article::PUBLISHED,
33 'publicationDate' => TIME_NOW,
34 'enableComments' => 1,
35 'userID' => $author->userID,
36 'username' => $author->username,
37 'isMultilingual' => 0,
38 'hasLabels' => 0
39 ],
40 'content' => [
41 0 => [
42 'title' => 'Test Article',
43 'teaser' => 'Test Article Teaser',
44 'content' => 'Test Article Content',
45 'imageID' => null,
46 'teaserImageID' => null
47 ]
48 ]
49 ]))->executeAction()['returnValues'];
50
51 return $article;
52 }
53 }