MediaParserTest::mediaFinderTest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 15
nc 1
nop 0
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