public function __construct(MockConfiguration $config, $code) { if (!$config->getName()) { throw new \InvalidArgumentException("MockConfiguration must contain a name"); } $this->config = $config; $this->code = $code; }
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; }
/** * @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); }
/** * @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()); }