MediaParserTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mediaFinderTest() 0 23 1
1
<?php
2
3
namespace AssetsFinder\Tests;
4
5
use AssetsFinder\MediaParser;
6
7
class MediaParserTest extends \PHPUnit_Framework_TestCase {
8
    
9
    /**
10
     * @test
11
     */
12
    public function mediaFinderTest()
13
    {
14
        $mediaParser = new MediaParser();
15
        $content = "this is a example first file http://www.mywebsite.com/mysample1.mp3 and second file is https://www.mywebsite.com/mysample3.mp4. This is the image link <img src='http://www.mywebsite.com/assets/images/testimage1.jpg' alt='test image' title='test image'> and second image <img src='http://www.mywebsite.com/assets/images/testimage3.png' alt='test png image' title='test png image'>";
16
        $content .= "this is a example first file http://www.mywebsite.com/mysample2.mp3 and second file is https://www.mywebsite.com/mysample4.mp4. This is the image link <img src='http://www.mywebsite.com/assets/images/testimage2.jpg' alt='test image' title='test image'>";
17
18
        $actualResult = $mediaParser->FindMedia($content);
19
        
20
        $expectedResult = array('mp3' => array(
21
            '0' => 'http://www.mywebsite.com/mysample1.mp3',
22
            '1' => 'http://www.mywebsite.com/mysample2.mp3'
23
        ),
24
        'mp4' => array(
25
            '0' => 'https://www.mywebsite.com/mysample3.mp4',
26
            '1' => 'https://www.mywebsite.com/mysample4.mp4'
27
        ),
28
        'jpg' => array(
29
            '0' => 'http://www.mywebsite.com/assets/images/testimage1.jpg',
30
            '1' => 'http://www.mywebsite.com/assets/images/testimage2.jpg'
31
        ));
32
        
33
        $this->assertEquals($expectedResult, $actualResult);
34
    }
35
}
36