Skip to content

Commit

Permalink
[BUGFIX] Set default doktype for post model (#83)
Browse files Browse the repository at this point in the history
Set the correct doktype via the post model. This is required when posts
are created via Extbase, in an action or a command for example.

Releases: master, 9.1, 9.0, 8.7, 7.6
Fixes: #82
  • Loading branch information
Phosphenius authored and benjaminkott committed May 26, 2019
1 parent cc245af commit 198fa92
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Classes/Domain/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace T3G\AgencyPack\Blog\Domain\Model;

use T3G\AgencyPack\Blog\Constants;
use T3G\AgencyPack\Blog\Domain\Repository\CommentRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
Expand All @@ -20,6 +21,13 @@

class Post extends AbstractEntity
{
/**
* The blog post doktype
*
* @var int
*/
protected $doktype = Constants::DOKTYPE_BLOG_POST;

/**
* The blog post title.
*
Expand Down Expand Up @@ -145,6 +153,14 @@ public function initializeObject(): void
$this->media = new ObjectStorage();
}

/**
* @return int
*/
public function getDoktype(): ?int
{
return $this->doktype;
}

/**
* @param Author $author
* @return Post
Expand Down
30 changes: 30 additions & 0 deletions Tests/Unit/Domain/Model/PostTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the package t3g/blog.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace T3G\AgencyPack\Blog\Tests\Unit\Domain\Model;

use T3G\AgencyPack\Blog\Constants;
use T3G\AgencyPack\Blog\Domain\Model\Post;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Tests for domains model News
*
*/
class PostTest extends UnitTestCase
{
/**
* @test
*/
public function doktypeEqualsConstant()
{
$post = new Post();
self::assertEquals(Constants::DOKTYPE_BLOG_POST, $post->getDoktype());
}
}

0 comments on commit 198fa92

Please sign in to comment.