Completed
Pull Request — 5.0 (#2163)
by Kevin
13:16
created

Tests/Form/MediaTokenTransformerTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\AdminBundle\Tests\Form;
4
5
use Kunstmaan\AdminBundle\Form\MediaTokenTransformer;
6
7
/**
8
 * Class MediaTokenTransformerTest
9
 *
10
 * @package Kunstmaan\AdminBundle\Tests\Form
11
 */
12
class MediaTokenTransformerTest extends \PHPUnit_Framework_TestCase
13
{
14
15
    public function testTransformCopiesDataSrcToSrc()
16
    {
17
        $transformer = new MediaTokenTransformer();
18
19
        $content = '<img src="[M1]" data-src="image.jpg?token=[M1]">';
20
21
        $expected = '<img src="image.jpg?token=%5BM1%5D">';
22
23
        $this->assertContains($expected, $transformer->transform($content));
24
    }
25
26 View Code Duplication
    public function testReverseTransformSetsSrcAndDataSrc()
0 ignored issues
show
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...
27
    {
28
        $transformer = new MediaTokenTransformer();
29
30
        $content = '<img src="image.jpg?token=%5BM1%5D">';
31
32
        $expected = '<img src="[M1]" data-src="image.jpg?token=[M1]">';
33
34
        $this->assertEquals($expected, $transformer->reverseTransform($content));
35
    }
36
37 View Code Duplication
    public function testReverseTransformPreservesAnchorHrefs()
0 ignored issues
show
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...
38
    {
39
        $transformer = new MediaTokenTransformer();
40
41
        $content = '<a href="%5BNT1%5D"></a>';
42
43
        $expected = '<a href="[NT1]"></a>';
44
45
        $this->assertEquals($expected, $transformer->reverseTransform($content));
46
    }
47
48
}
49