MyBuilder\Conductor\Conductor::updatePackages PHP Method

updatePackages() public method

public updatePackages ( $paths, PackageZipper $packageZipper )
$packageZipper PackageZipper
    public function updatePackages($paths, PackageZipper $packageZipper)
    {
        $finder = new Finder();
        $finder->files()->exclude('vendor')->name('composer.json')->depth(0);
        $results = array();
        foreach ($finder->in($paths) as $file) {
            $results[] = $packageZipper->zip($file);
        }
        return $results;
    }

Usage Example

示例#1
0
 public function test_it_should_update_all_packages()
 {
     $zipperMock = $this->getMock('MyBuilder\\Conductor\\PackageZipper', array(), array(array()));
     $zipperMock->expects($this->any())->method('zip')->will($this->returnCallback(function ($a) {
         return $a;
     }));
     $files = $this->conductor->updatePackages(array(__DIR__ . '/fixtures/packages/*'), $zipperMock);
     $this->assertEquals(array(__DIR__ . '/fixtures/packages/package-a/composer.json', __DIR__ . '/fixtures/packages/package-a-changed/composer.json'), array_map(null, $files));
 }