Completed
Push — master ( 7de777...9be641 )
by
unknown
11:28
created

testParseInvalidProviderReferenceShort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Tests\Unit\Provider;
4
5
use MediaMonks\SonataMediaBundle\Exception\InvalidProviderUrlException;
6
use MediaMonks\SonataMediaBundle\Provider\AbstractProvider;
7
use MediaMonks\SonataMediaBundle\Provider\YouTubeProvider;
8
9
class YoutubeProviderTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testParseProviderReference()
12
    {
13
        $youtube = new YouTubeProvider();
14
        $this->assertEquals('uN2nqdRLhQ8', $youtube->parseProviderReference('https://www.youtube.com/watch?v=uN2nqdRLhQ8'));
15
        $this->assertEquals('uN2nqdRLhQ8', $youtube->parseProviderReference('https://www.youtube.com/watch?v=uN2nqdRLhQ8&foo=bar'));
16
        $this->assertEquals('uN2nqdRLhQ8', $youtube->parseProviderReference('https://youtu.be/uN2nqdRLhQ8'));
17
        $this->assertEquals('uN2nqdRLhQ8', $youtube->parseProviderReference('https://youtu.be/uN2nqdRLhQ8?foo=bar'));
18
        $this->assertEquals('uN2nqdRLhQ8', $youtube->parseProviderReference('uN2nqdRLhQ8'));
19
    }
20
21
    public function testParseInvalidProviderReference()
22
    {
23
        $this->setExpectedException(InvalidProviderUrlException::class);
24
        $youtube = new YouTubeProvider();
25
        $youtube->parseProviderReference('https://www.youtube.com/watch?foo=bar');
26
    }
27
28
    public function testParseInvalidProviderReference2()
29
    {
30
        $this->setExpectedException(InvalidProviderUrlException::class);
31
        $youtube = new YouTubeProvider();
32
        $youtube->parseProviderReference('https://www.youtube.com');
33
    }
34
35
    public function testParseInvalidProviderReferenceShort()
36
    {
37
        $this->setExpectedException(InvalidProviderUrlException::class);
38
        $youtube = new YouTubeProvider();
39
        $youtube->parseProviderReference('https://youtu.be');
40
    }
41
42 View Code Duplication
    public function testSupports()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $provider = new YouTubeProvider();
45
        $this->assertFalse($provider->supports(AbstractProvider::SUPPORT_DOWNLOAD));
46
        $this->assertTrue($provider->supports(AbstractProvider::SUPPORT_EMBED));
47
        $this->assertTrue($provider->supports(AbstractProvider::SUPPORT_IMAGE));
48
        $this->assertFalse($provider->supports('foo'));
49
    }
50
}
51