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

YoutubeProviderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 66
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testYoutube() 0 32 1
B testUnexistingVideo() 0 30 1
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Tests\Functional;
4
5
class YoutubeProviderTest extends AbstractOembedProviderTestAbstract
6
{
7
    public function testYoutube()
8
    {
9
        $this->providerFlow(
10
            'youtube',
11
            'https://www.youtube.com/watch?v=uN2nqdRLhQ8',
12
            [
13
                'providerReference' => 'uN2nqdRLhQ8',
14
                'title' => 'MediaMonks Mixtape Vol  II',
15
                'description' => '',
16
                'authorName' => 'MediaMonks',
17
                'copyright' => '',
18
                'focalPoint' => '50-50'
19
            ]
20
        );
21
22
        $crawler = $this->client->request('GET', '/twig');
23
24
        $this->assertEquals(
25
            2,
26
            $crawler->filter('img')->count()
27
        );
28
29
        $this->assertEquals(
30
            1,
31
            $crawler->filter('iframe')->count()
32
        );
33
34
        $this->assertEquals(
35
            0,
36
            $crawler->filter('a')->count()
37
        );
38
    }
39
40
    public function testUnexistingVideo()
41
    {
42
        $provider = 'youtube';
43
        $providerReference = 'foobar123123123';
44
45
        \VCR\VCR::insertCassette('youtube_unexisting');
46
        $crawler = $this->client->request('GET', self::BASE_PATH.'create?provider='.$provider);
47
48
        $form = $crawler->selectButton('Create')->form();
49
50
        $this->assertSonataFormValues(
51
            $form,
52
            [
53
                'provider' => $provider,
54
            ]
55
        );
56
57
        $this->updateSonataFormValues(
58
            $form,
59
            [
60
                'providerReference' => $providerReference,
61
            ]
62
        );
63
64
        $this->client->submit($form);
65
66
        $this->assertContains('does not exist', $this->client->getResponse()->getContent());
67
68
        \VCR\VCR::eject();
69
    }
70
}
71