Completed
Push — master ( ecffef...7362a8 )
by Derek
02:15
created

Assertions   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertSameAsToString() 0 9 2
1
<?php
2
namespace Subreality\Dilmun\Anshar\PhpUnit;
3
4
use PHPUnit_Framework_TestCase as TestCase;
5
6
/**
7
 * Class Assertions
8
 * @package Subreality\Dilmun\Anshar\PhpUnit
9
 */
10
class Assertions
11
{
12
    /** @var  TestCase */
13
    public static $test_case;
14
15
    /**
16
     * Asserts that the given expected string is the same as the string returned by an object instance's __toString
17
     * magic method.
18
     *
19
     * @throws \PHPUnit_Framework_ExpectationFailedException provided an instance of an object with no __toString
20
     * method.
21
     *
22
     * @param string $expected
23
     * @param object $test_instance
24
     */
25 10
    public static function assertSameAsToString($expected, $test_instance)
26
    {
27
        try {
28 10
            $actual = (string) $test_instance;
29 9
            TestCase::assertSame($expected, $actual);
30 10
        } catch (\PHPUnit_Framework_Error $error) {
31 1
            throw new \PHPUnit_Framework_ExpectationFailedException("Cannot convert object to string");
32
        }
33 8
    }
34
}
35