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 310189f commit 6155665
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Classes/Domain/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@

namespace T3G\AgencyPack\Blog\Domain\Model;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use T3G\AgencyPack\Blog\Constants;
use T3G\AgencyPack\Blog\Domain\Repository\CommentRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
Expand All @@ -32,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 @@ -151,6 +147,14 @@ public function initializeObject()
$this->media = new ObjectStorage();
}

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

/**
* @param Author $author
*/
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 6155665

Please sign in to comment.