예제 #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;
 }