EmbedlyBlockTest::testWidthAcceptsPx()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Chillu\ElementalEmbedlyBlock\Tests\Block;
3
4
use Chillu\ElementalEmbedlyBlock\Block\EmbedlyBlock;
5
use SilverStripe\Dev\SapphireTest;
6
7
class EmbedlyBlockTest extends SapphireTest
8
{
9
    public function testWidthAcceptsPercent()
10
    {
11
        $block = new EmbedlyBlock([
12
            'Width' => '100%'
13
        ]);
14
        $this->assertEquals('100%', $block->getWidthAttribute());
15
    }
16
17
    public function testWidthAcceptsPx()
18
    {
19
        $block = new EmbedlyBlock([
20
            'Width' => '100px'
21
        ]);
22
        $this->assertEquals('100px', $block->getWidthAttribute());
23
    }
24
25
    public function testWidthSanitisesInvalidValues()
26
    {
27
        $block = new EmbedlyBlock([
28
            'Width' => 'invalid'
29
        ]);
30
        $this->assertEquals('', $block->getWidthAttribute());
31
    }
32
}
33