Completed
Push — master ( c8c53b...aae31f )
by Jordi Sala
10s
created

PHPUnit_Framework_TestCase::expectException()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 16
rs 9.2
c 1
b 0
f 0
cc 4
eloc 8
nc 5
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[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 Sonata\SeoBundle\Tests\Helpers;
13
14
/**
15
 * This is helpers class for supporting old and new PHPUnit versions.
16
 *
17
 * @todo NEXT_MAJOR: Remove this class when dropping support for < PHPUnit 5.4.
18
 *
19
 * @author Oskar Stark <[email protected]>
20
 */
21
class PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function expectException($exception, $message = '', $code = null)
27
    {
28
        if (is_callable('parent::expectException')) {
29
            parent::expectException($exception);
30
31
            if ($message !== '') {
32
                parent::expectExceptionMessage($message);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (expectExceptionMessage() instead of expectException()). Are you sure this is correct? If so, you might want to change this to $this->expectExceptionMessage().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
33
            }
34
35
            if ($code !== null) {
36
                parent::expectExceptionCode($code);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (expectExceptionCode() instead of expectException()). Are you sure this is correct? If so, you might want to change this to $this->expectExceptionCode().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
37
            }
38
        }
39
40
        return parent::setExpectedException($exception, $message, $code);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setExpectedException() instead of expectException()). Are you sure this is correct? If so, you might want to change this to $this->setExpectedException().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    protected function createMock($originalClassName)
47
    {
48
        if (is_callable('parent::createMock')) {
49
            return parent::createMock($originalClassName);
50
        }
51
52
        return parent::getMockBuilder($originalClassName)
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getMockBuilder() instead of createMock()). Are you sure this is correct? If so, you might want to change this to $this->getMockBuilder().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
53
            ->disableOriginalConstructor()
54
            ->disableOriginalClone()
55
            ->disableArgumentCloning()
56
            ->getMock();
57
    }
58
}
59