Ejemplo n.º 1
0
 /**
  * @param Alias $newAlias
  * @param $hasAlias
  * @param bool $willBeSaved
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 private function provideAliasManager(Alias $newAlias, $hasAlias, $willBeSaved)
 {
     $oldAlias = clone $newAlias;
     $oldAlias->setDescription($newAlias->getDescription() . '_old');
     $oldAlias->setPackage($newAlias->getPackage() . '_old');
     $oldAlias->setVersion($newAlias->getVersion() . '_old');
     $aliasManager = $this->getMockBuilder('Samurai\\Alias\\AliasManager')->disableOriginalConstructor()->getMock();
     $aliasManager->expects($this->once())->method('has')->with($newAlias->getName())->will($this->returnValue($hasAlias));
     $aliasManager->expects($this->exactly((int) $willBeSaved))->method('add')->with($this->equalTo($newAlias));
     $aliasManager->expects($this->any())->method('get')->with($newAlias->getName())->will($this->returnValue($oldAlias));
     return $aliasManager;
 }
Ejemplo n.º 2
0
 /**
  * @param Alias $alias
  * @param $hasAlias
  * @param bool $willBeRemoved
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 private function provideAliasManager(Alias $alias, $hasAlias, $willBeRemoved)
 {
     $aliasManager = $this->getMockBuilder('Samurai\\Alias\\AliasManager')->disableOriginalConstructor()->getMock();
     $aliasManager->expects($this->once())->method('hasLocal')->with($alias->getName())->will($this->returnValue($hasAlias));
     if ($hasAlias) {
         $aliasManager->expects($this->once())->method('get')->with($alias->getName())->will($this->returnValue($alias));
     }
     $aliasManager->expects($this->exactly((int) $willBeRemoved))->method('remove')->with($this->equalTo($alias->getName()));
     return $aliasManager;
 }
Ejemplo n.º 3
0
 /**
  * @param Alias $newAlias
  * @return Alias
  */
 private function getInitialAlias(Alias $newAlias)
 {
     return $this->getService('alias_manager')->get($newAlias->getName());
 }
Ejemplo n.º 4
0
 /**
  * @param Alias $alias
  * @param string $useMethod
  * @param bool $hasAlias
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 private function provideAliasManager(Alias $alias, $useMethod, $hasAlias)
 {
     $aliasManager = $this->getMockBuilder('Samurai\\Alias\\AliasManager')->disableOriginalConstructor()->getMock();
     $aliasManager->expects($this->exactly((int) ($useMethod === 'getGlobal')))->method('getGlobal')->will($this->returnValue([$alias->getName() => $alias]));
     $aliasManager->expects($this->exactly((int) ($useMethod === 'getLocal')))->method('getLocal')->will($this->returnValue([$alias->getName() => $alias]));
     $aliasManager->expects($this->exactly((int) ($useMethod === 'getAll' || !$hasAlias)))->method('getAll')->will($this->returnValue([$alias->getName() => $alias]));
     $aliasManager->expects($this->exactly((int) ($useMethod === 'get' && $hasAlias)))->method('get')->will($this->returnValue($alias));
     $aliasManager->expects($this->exactly((int) ($useMethod === 'get')))->method('has')->will($this->returnValue($hasAlias));
     return $aliasManager;
 }