mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\Tests\integration\extenders;
|
|
|
|
use Flarum\Extend;
|
|
use Flarum\Post\AbstractEventPost;
|
|
use Flarum\Post\MergeableInterface;
|
|
use Flarum\Post\Post;
|
|
use Flarum\Tests\integration\TestCase;
|
|
|
|
class PostTest extends TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
*/
|
|
public function custom_post_type_doesnt_exist_by_default()
|
|
{
|
|
$this->assertArrayNotHasKey('customPost', Post::getModels());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function custom_post_type_exists_if_added()
|
|
{
|
|
$this->extend((new Extend\Post)->type(PostTestCustomPost::class));
|
|
|
|
// Needed for extenders to be booted
|
|
$this->app();
|
|
|
|
$this->assertArrayHasKey('customPost', Post::getModels());
|
|
}
|
|
}
|
|
|
|
class PostTestCustomPost extends AbstractEventPost implements MergeableInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static $type = 'customPost';
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function saveAfter(Post $previous = null)
|
|
{
|
|
$this->save();
|
|
|
|
return $this;
|
|
}
|
|
}
|