1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Assert\Tests; |
4
|
|
|
|
5
|
|
|
use Assert\Assertion; |
6
|
|
|
|
7
|
|
|
class PR142_AllowOverridingStringifyTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
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 |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
protected static function stringify($value) |
37
|
|
|
{ |
38
|
|
|
return '***' . parent::stringify($value) . '***'; |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
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
.