-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathPostContentIsRenderingTest.php
42 lines (35 loc) · 1.39 KB
/
PostContentIsRenderingTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Modules\Blog\Tests;
use Illuminate\Support\Facades\Event;
use Modules\Blog\Entities\Status;
use Modules\Blog\Events\PostContentIsRendering;
class PostContentIsRenderingTest extends BaseBlogTestCase
{
/** @test */
public function it_can_change_final_content()
{
Event::listen(PostContentIsRendering::class, function (PostContentIsRendering $event) {
$event->setContent('<strong>' . $event->getOriginal() . '</strong>');
});
$post = $this->post->create([
'en' => ['title' => 'lorem en', 'slug' => 'something', 'content' => 'My Post Body'],
'fr' => ['title' => 'lorem fr', 'slug' => 'quelque-chose', 'content' => 'My Post Body'],
'category_id' => 1,
'status' => Status::PUBLISHED,
'tags' => [],
]);
$this->assertEquals('<strong>My Post Body</strong>', $post->content);
}
/** @test */
public function it_doesnt_alter_content_if_no_listeners()
{
$post = $this->post->create([
'en' => ['title' => 'lorem en', 'slug' => 'something', 'content' => 'My Post Body'],
'fr' => ['title' => 'lorem fr', 'slug' => 'quelque-chose', 'content' => 'My Post Body'],
'category_id' => 1,
'status' => Status::PUBLISHED,
'tags' => [],
]);
$this->assertEquals('My Post Body', $post->content);
}
}