@@ -56,6 +56,7 @@ public function testInstall()
5656} ' ;
5757
5858 $ this ->filesystem
59+ ->shouldReceive ('exists ' )->with (getcwd () . '/bower_components/jquery/bower.json ' )->andReturn (false )
5960 ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery/foo ' , 'foo content ' )
6061 ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery/.bower.json ' , $ json )
6162 ->shouldReceive ('touch ' )->with (getcwd () . '/bower_components/jquery/foo ' , 1396303200 )
@@ -90,6 +91,7 @@ public function testUpdate()
9091} ' ;
9192
9293 $ this ->filesystem
94+ ->shouldReceive ('exists ' )->with (getcwd () . '/bower_components/jquery/bower.json ' )->andReturn (false )
9395 ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery/foo ' , 'foo content ' )
9496 ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery/.bower.json ' , $ json )
9597 ->shouldReceive ('touch ' )->with (getcwd () . '/bower_components/jquery/foo ' , 1396303200 )
@@ -98,6 +100,52 @@ public function testUpdate()
98100 $ this ->installer ->update ($ package );
99101 }
100102
103+ public function testInstallAndMergeInfoWithBowerJsonContents ()
104+ {
105+ $ package = Mockery::mock ('Bowerphp\Package\PackageInterface ' );
106+
107+ $ info = [
108+ 'name ' => 'jquery-ui ' ,
109+ 'version ' => '1.12.1 ' ,
110+ 'dependencies ' => [
111+ 'jquery ' => '>=1.6 ' ,
112+ ],
113+ ];
114+
115+ $ package
116+ ->shouldReceive ('getName ' )->andReturn ('jquery-ui ' )
117+ ->shouldReceive ('getVersion ' )->andReturn ('1.12.1 ' )
118+ ->shouldReceive ('getInfo ' )->andReturn ([])->once ()
119+ ->shouldReceive ('setInfo ' )->with ($ info )->andReturnSelf ()
120+ ->shouldReceive ('getInfo ' )->andReturn ($ info );
121+
122+ $ json = '{
123+ "name": "jquery-ui",
124+ "version": "1.12.1",
125+ "dependencies": {
126+ "jquery": ">=1.6"
127+ }
128+ } ' ;
129+
130+ $ this ->zipArchive
131+ ->shouldReceive ('open ' )->with ('./tmp/jquery-ui ' )->andReturn (true )
132+ ->shouldReceive ('getNumFiles ' )->andReturn (1 )
133+ ->shouldReceive ('getNameIndex ' )->with (0 )->andReturn ('jquery-ui ' )
134+ ->shouldReceive ('statIndex ' )->andReturn (['name ' => 'jquery-ui/bower.json ' , 'size ' => 107 , 'mtime ' => 1483795099 ])
135+ ->shouldReceive ('getStream ' )->with ('jquery-ui/bower.json ' )->andReturn ($ json )
136+ ->shouldReceive ('close ' );
137+
138+ $ this ->filesystem
139+ ->shouldReceive ('exists ' )->with (getcwd () . '/bower_components/jquery-ui/bower.json ' )->andReturn (true )
140+ ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery-ui/.bower.json ' , $ json )
141+ ->shouldReceive ('write ' )->with (getcwd () . '/bower_components/jquery-ui/bower.json ' , $ json )
142+ ->shouldReceive ('touch ' )->with (getcwd () . '/bower_components/jquery-ui/bower.json ' , 1483795099 )
143+ ->shouldReceive ('read ' )->with (getcwd () . '/bower_components/jquery-ui/bower.json ' )->andReturn ($ json )
144+ ;
145+
146+ $ this ->installer ->install ($ package );
147+ }
148+
101149 /**
102150 * @expectedException \RuntimeException
103151 * @expectedExceptionMessage Unable to open zip file ./tmp/jquery.
0 commit comments