it_can_change_final_content()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Modules\Block\Tests\Integration;
4
5
use Illuminate\Support\Facades\Event;
6
use Modules\Block\Events\BlockContentIsRendering;
7
8
class BlockContentIsRenderingTest extends BaseBlockTest
9
{
10
    /** @test */
11
    public function it_can_change_final_content()
12
    {
13
        Event::listen(BlockContentIsRendering::class, function (BlockContentIsRendering $event) {
14
            $event->setBody('<strong>' . $event->getOriginal() . '</strong>');
15
        });
16
17
        $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'My Block Body'], 'fr' => ['body' => 'lorem fr']]);
18
19
        $this->assertEquals('<strong>My Block Body</strong>', $block->body);
20
    }
21
22
    /** @test */
23
    public function it_doesnt_alter_content_if_no_listeners()
24
    {
25
        $block = $this->block->create(['name' => 'testBlock', 'en' => ['body' => 'My Block Body'], 'fr' => ['body' => 'lorem fr']]);
26
27
        $this->assertEquals('My Block Body', $block->body);
28
    }
29
}
30