コード例 #1
0
 public function __construct(MockConfiguration $config, $code)
 {
     if (!$config->getName()) {
         throw new \InvalidArgumentException("MockConfiguration must contain a name");
     }
     $this->config = $config;
     $this->code = $code;
 }
コード例 #2
0
 public function generate(MockConfiguration $config)
 {
     $hash = $config->getHash();
     if (isset($this->cache[$hash])) {
         return $this->cache[$hash];
     }
     $definition = $this->generator->generate($config);
     $this->cache[$hash] = $definition;
     return $definition;
 }
コード例 #3
0
 /**
  * @test
  */
 public function itShouldNotAddReturnTypeHintIfOneIsNotFound()
 {
     $targetClass = DefinedTargetClass::factory('Mockery\\Test\\Generator\\StringManipulation\\Pass\\MagicReturnDummy');
     $this->mockedConfiguration->shouldReceive('getTargetClass')->andReturn($targetClass)->byDefault();
     $code = $this->pass->apply('public static function __isset($parameter) {}', $this->mockedConfiguration);
     $this->assertContains(') {', $code);
 }
コード例 #4
0
 /**
  * @test
  */
 public function shouldBringIteratorAggregateToHeadOfTargetListIfTraversablePresent()
 {
     $config = new MockConfiguration(array("Mockery\\Generator\\TestTraversableInterface3"));
     $interfaces = $config->getTargetInterfaces();
     $this->assertEquals(2, count($interfaces));
     $this->assertEquals("IteratorAggregate", $interfaces[0]->getName());
     $this->assertEquals("Mockery\\Generator\\TestTraversableInterface3", $interfaces[1]->getName());
 }