1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2016 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor\DomainModel\Renderer\Asset; |
14
|
|
|
|
15
|
|
|
use phpDocumentor\DomainModel\Path; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @coversDefaultClass phpDocumentor\DomainModel\Renderer\Asset\Folder |
19
|
|
|
* @covers ::<private> |
20
|
|
|
*/ |
21
|
|
|
final class FolderTest extends \PHPUnit_Framework_TestCase |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @test |
25
|
|
|
* @coversNothing |
26
|
|
|
*/ |
27
|
|
|
public function itShouldBeACollection() |
28
|
|
|
{ |
29
|
|
|
$folder = new Folder(new Path('images'), []); |
30
|
|
|
$this->assertInstanceOf(\ArrayObject::class, $folder); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @test |
35
|
|
|
* @covers ::__construct |
36
|
|
|
* @covers ::path |
37
|
|
|
*/ |
38
|
|
|
public function itShouldExposeThePathForThisFolder() |
39
|
|
|
{ |
40
|
|
|
$path = new Path('images'); |
41
|
|
|
|
42
|
|
|
$folder = new Folder($path, []); |
43
|
|
|
|
44
|
|
|
$this->assertSame($path, $folder->path()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @test |
49
|
|
|
* @covers ::offsetSet |
50
|
|
|
*/ |
51
|
|
|
public function itCanAddAdditionalPathsInThisFolder() |
52
|
|
|
{ |
53
|
|
|
$folder = new Folder(new Path('images'), []); |
54
|
|
|
$path = new Path('cats.png'); |
55
|
|
|
|
56
|
|
|
$folder[] = $path; |
57
|
|
|
|
58
|
|
|
$this->assertSame($path, $folder[0]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @test |
63
|
|
|
* @covers ::__construct |
64
|
|
|
*/ |
65
|
|
|
public function itShouldErrorWhenTheConstructorReceivesSomethingOtherThanAPathObject() |
66
|
|
|
{ |
67
|
|
|
$this->setExpectedException(\InvalidArgumentException::class); |
68
|
|
|
|
69
|
|
|
new Folder(new Path('images'), [new \stdClass()]); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @test |
74
|
|
|
* @covers ::offsetSet |
75
|
|
|
*/ |
76
|
|
|
public function itShouldErrorWhenTheSomethingOtherThanAPathObjectIsAdded() |
77
|
|
|
{ |
78
|
|
|
$this->setExpectedException(\InvalidArgumentException::class); |
79
|
|
|
|
80
|
|
|
$folder = new Folder(new Path('images'), []); |
81
|
|
|
|
82
|
|
|
$folder[] = new \stdClass(); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: