Esempio n. 1
0
 public function testErrorMessages()
 {
     $packageMock = $this->getMock('Composer\\Package\\PackageInterface');
     $packageMock->expects($this->any())->method('getDistUrl')->will($this->returnValue('file://' . __FILE__));
     $io = $this->getMock('Composer\\IO\\IOInterface');
     $downloader = new ZipDownloader($io);
     try {
         $downloader->download($packageMock, sys_get_temp_dir() . '/composer-zip-test');
         $this->fail('Download of invalid zip files should throw an exception');
     } catch (\UnexpectedValueException $e) {
         $this->assertContains('is not a zip archive', $e->getMessage());
     }
 }
 public function testErrorMessages()
 {
     $packageMock = $this->getMock('Composer\\Package\\PackageInterface');
     $packageMock->expects($this->any())->method('getDistUrl')->will($this->returnValue($distUrl = 'file://' . __FILE__));
     $packageMock->expects($this->any())->method('getDistUrls')->will($this->returnValue(array($distUrl)));
     $packageMock->expects($this->atLeastOnce())->method('getTransportOptions')->will($this->returnValue(array()));
     $io = $this->getMock('Composer\\IO\\IOInterface');
     $config = $this->getMock('Composer\\Config');
     $config->expects($this->any())->method('get')->with('vendor-dir')->will($this->returnValue($this->testDir));
     $downloader = new ZipDownloader($io, $config);
     try {
         $downloader->download($packageMock, sys_get_temp_dir() . '/composer-zip-test');
         $this->fail('Download of invalid zip files should throw an exception');
     } catch (\UnexpectedValueException $e) {
         $this->assertContains('is not a zip archive', $e->getMessage());
     }
 }