public function setUp()
    {
        $this->config = $this->getMock('Composer\Config');
        $this->config->expects($this->any())
            ->method('get')
            ->will($this->returnCallback(function ($key) {
                switch ($key) {
                    case 'cache-repo-dir':
                        return sys_get_temp_dir() . '/composer-test-repo-cache';
                    case 'vendor-dir':
                        return sys_get_temp_dir() . '/composer-test/vendor';
                }

                return null;
            }));

        $this->rootPackage = $this->getMock('Composer\Package\RootPackageInterface');
        $this->package = $this->getMock('Composer\Package\PackageInterface');
        $this->package->expects($this->any())
            ->method('getName')
            ->will($this->returnValue('foo-asset/foo'));

        $this->composer = $this->getMock('Composer\Composer');
        $this->composer->expects($this->any())
            ->method('getPackage')
            ->will($this->returnValue($this->rootPackage));
        $this->composer->expects($this->any())
            ->method('getConfig')
            ->will($this->returnValue($this->config));
    }
 /**
  * @param string $composerType
  *
  * @return PackageEvent
  */
 protected function createEvent($composerType)
 {
     $this->package->expects($this->any())->method('getType')->will($this->returnValue($composerType));
     $this->operation->expects($this->any())->method('getTargetPackage')->will($this->returnValue($this->package));
     $this->operation->expects($this->any())->method('getPackage')->will($this->returnValue($this->package));
     return new PackageEvent('foo-event', $this->composer, $this->io, true, $this->operation);
 }
 /**
  * @param string $composerType
  *
  * @return PackageEvent
  */
 protected function createEvent($composerType)
 {
     $this->package->expects($this->any())->method('getType')->will($this->returnValue($composerType));
     $this->operation->expects($this->any())->method('getTargetPackage')->will($this->returnValue($this->package));
     $this->operation->expects($this->any())->method('getPackage')->will($this->returnValue($this->package));
     /* @var PolicyInterface $policy */
     $policy = $this->getMock('Composer\\DependencyResolver\\PolicyInterface');
     /* @var Pool $pool */
     $pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->disableOriginalConstructor()->getMock();
     /* @var CompositeRepository $installedRepo */
     $installedRepo = $this->getMockBuilder('Composer\\Repository\\CompositeRepository')->disableOriginalConstructor()->getMock();
     /* @var Request $request */
     $request = $this->getMockBuilder('Composer\\DependencyResolver\\Request')->disableOriginalConstructor()->getMock();
     $operations = array($this->getMock('Composer\\DependencyResolver\\Operation\\OperationInterface'));
     return new PackageEvent('foo-event', $this->composer, $this->io, true, $policy, $pool, $installedRepo, $request, $operations, $this->operation);
 }
 /**
  * @test
  */
 public function caseSensitivityConfigIsExtractedFromVeryDeprecatedKey()
 {
     $this->packageMock->expects($this->any())->method('getExtra')->willReturn(array('autoload-case-sensitivity' => false));
     $subject = new Config($this->packageMock, $this->IOMock);
     $this->assertFalse($subject->get('autoload-case-sensitivity'));
 }
Beispiel #5
0
 private function packageExpects($method, $value)
 {
     $this->package->expects($this->any())->method($method)->will($this->returnValue($value));
     return $this;
 }