|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bowerphp\Test\Package; |
|
4
|
|
|
|
|
5
|
|
|
use Bowerphp\Package\Package; |
|
6
|
|
|
use Bowerphp\Test\BowerphpTestCase; |
|
7
|
|
|
use Mockery; |
|
8
|
|
|
|
|
9
|
|
|
class PackageTest extends BowerphpTestCase |
|
10
|
|
|
{ |
|
11
|
|
|
public function testSetVersion() |
|
12
|
|
|
{ |
|
13
|
|
|
$package = new Package('foo', null, '1.0.0'); |
|
14
|
|
|
$package->setVersion('1.1.0'); |
|
15
|
|
|
|
|
16
|
|
|
$this->assertEquals('1.1.0', $package->getVersion()); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function testSetRepository() |
|
20
|
|
|
{ |
|
21
|
|
|
$repository = Mockery::mock('Bowerphp\Repository\RepositoryInterface'); |
|
22
|
|
|
$package = new Package('foo', null, '1.0.0'); |
|
23
|
|
|
|
|
24
|
|
|
$package->setRepository($repository); |
|
25
|
|
|
$this->assertTrue(true); // jsut avoid risky test |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @expectedException \LogicException |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testCannotChangeRepository() |
|
32
|
|
|
{ |
|
33
|
|
|
$repository = Mockery::mock('Bowerphp\Repository\RepositoryInterface'); |
|
34
|
|
|
$repository2 = Mockery::mock('Bowerphp\Repository\RepositoryInterface'); |
|
35
|
|
|
$package = new Package('foo', null, '1.0.0'); |
|
36
|
|
|
|
|
37
|
|
|
$package->setRepository($repository); |
|
38
|
|
|
$package->setRepository($repository2); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testGetUniqueName() |
|
42
|
|
|
{ |
|
43
|
|
|
$package = new Package('foo', null, '1.0.0'); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertEquals('foo-1.0.0', $package->getUniqueName()); |
|
46
|
|
|
$this->assertEquals('foo-1.0.0', $package->__toString()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testRequires() |
|
50
|
|
|
{ |
|
51
|
|
|
$package = new Package('foo', null, '1.0.0'); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertEquals([], $package->getRequires()); |
|
54
|
|
|
|
|
55
|
|
|
$package->setRequires(['baz']); |
|
56
|
|
|
$this->assertEquals(['baz'], $package->getRequires()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testGetInfo() |
|
60
|
|
|
{ |
|
61
|
|
|
$package = new Package('foo', null, '1.0.0', null, ['url' => 'bar']); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$this->assertEquals(['url' => 'bar'], $package->getInfo()); |
|
64
|
|
|
|
|
65
|
|
|
$package->setInfo(['url' => 'baz']); |
|
66
|
|
|
$this->assertEquals(['url' => 'baz'], $package->getInfo()); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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: