File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function getPackages(): array
24
24
$ packages = [];
25
25
foreach ($ this ->object ->{'packages ' } as $ p ) {
26
26
$ name = $ p ->name ;
27
- $ url = $ p ->homepage ;
27
+ $ url = property_exists ( $ p , ' homepage ' ) ? $ p ->homepage : '' ;
28
28
$ packages [] = new Package ($ name , $ url );
29
29
}
30
30
return $ packages ;
Original file line number Diff line number Diff line change @@ -47,8 +47,29 @@ public function testNormal(): void
47
47
$ this ->assertSame (1 , count ($ packages ));
48
48
$ this ->assertSame ('doctrine/instantiator ' , $ packages [0 ]->getName ());
49
49
$ this ->assertSame ('https://www.doctrine-project.org/projects/instantiator.html ' , $ packages [0 ]->getUrl ());
50
- // $this->assertSame('x', $packages[0]->getfilePath());
51
- // $this->assertSame('', $packages[0]->getContent());
50
+ }
51
+
52
+ public function testNoHomepage (): void
53
+ {
54
+
55
+ $ json = <<<EOJ
56
+ {
57
+ "packages": [
58
+ {
59
+ "name": "doctrine/instantiator",
60
+ "version": "1.5.0",
61
+ "license": [
62
+ "MIT"
63
+ ]
64
+ }
65
+ ]
66
+ }
67
+ EOJ ;
68
+ $ sut = new LockFile ($ json );
69
+ $ packages = $ sut ->getPackages ();
52
70
71
+ $ this ->assertSame (1 , count ($ packages ));
72
+ $ this ->assertSame ('doctrine/instantiator ' , $ packages [0 ]->getName ());
73
+ $ this ->assertSame ('' , $ packages [0 ]->getUrl ());
53
74
}
54
75
}
You can’t perform that action at this time.
0 commit comments