Completed
Push — master ( ac6391...9b00f4 )
by Michael
12:56
created

ParseExceptionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 84.62 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 22
loc 26
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMessage() 11 11 2
A testGetMessageWithUnicodeInFilename() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Symfony\Component\Yaml\Tests;
13
14
use Symfony\Component\Yaml\Exception\ParseException;
15
16
class ParseExceptionTest extends \PHPUnit_Framework_TestCase
17
{
18 View Code Duplication
    public function testGetMessage()
19
    {
20
        $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
21
        if (PHP_VERSION_ID >= 50400) {
22
            $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
23
        } else {
24
            $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
25
        }
26
27
        $this->assertEquals($message, $exception->getMessage());
28
    }
29
30 View Code Duplication
    public function testGetMessageWithUnicodeInFilename()
31
    {
32
        $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
33
        if (PHP_VERSION_ID >= 50400) {
34
            $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
35
        } else {
36
            $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
37
        }
38
39
        $this->assertEquals($message, $exception->getMessage());
40
    }
41
}
42