Completed
Push — master ( 5ab27e...dbe44c )
by Richard
02:00
created

testInvalidStringWithOverriddenStringify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace Assert\Tests;
4
5
use Assert\Assertion;
6
7
class PR142_AllowOverridingStringifyTest 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...
8
{
9
    public static function dataInvalidString()
10
    {
11
        return array(
12
            array(1.23, 'Value "***1.23***" expected to be string, type double given.'),
13
            array(false, 'Value "***<FALSE>***" expected to be string, type boolean given.'),
14
            array(new \ArrayObject, 'Value "***ArrayObject***" expected to be string, type object given.'),
15
            array(null, 'Value "***<NULL>***" expected to be string, type NULL given.'),
16
            array(10, 'Value "***10***" expected to be string, type integer given.'),
17
            array(true, 'Value "***<TRUE>***" expected to be string, type boolean given.'),
18
        );
19
    }
20
21
    /**
22
     * @dataProvider dataInvalidString
23
     *
24
     * @param string $invalidString
25
     * @param string $exceptionMessage
26
     */
27
    public function testInvalidStringWithOverriddenStringify($invalidString, $exceptionMessage)
28
    {
29
        $this->setExpectedException('Assert\AssertionFailedException', $exceptionMessage, Assertion::INVALID_STRING);
30
        PR142_OverrideStringify::string($invalidString);
31
    }
32
}
33
34
class PR142_OverrideStringify extends Assertion
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
35
{
36
    protected static function stringify($value)
37
    {
38
        return '***' . parent::stringify($value) . '***';
39
    }
40
}
41