public function setUp() { $this->templateLoader = Doubles::fromClass(TemplateLoader::FQCN); $this->templateCompiler = Doubles::fromClass(TemplateCompiler::FQCN); $this->fileSystem = Doubles::fromClass('\\Dancras\\Groundwork\\FileSystem'); $this->codeGenerator = new CodeGenerator($this->templateLoader, $this->templateCompiler, $this->fileSystem); }
public function testFluentInterface() { $double = Doubles::fromClass('\\SomeClass'); $double->stub('foo', 'bar')->stub('hello', 'world'); $this->assertSame('bar', $double->foo()); $this->assertSame('world', $double->hello()); }
public function testDoesNothingWhenMethodExpected() { $expectationComponent = Doubles::fromClass('\\Doubles\\Expectation\\ExpectationComponent'); $expectationComponent->stub('isMethodExpected', true); $component = new PartialComponent($expectationComponent); $this->assertNull($component->whenMethodCalled('foo', array())); }
public function setUp() { $this->parser = Doubles::fromClass(PHPInputParser::FQCN); $this->fileSystem = Doubles::fromClass('\\Dancras\\Groundwork\\FileSystem'); $this->fileSystem->stub('isFile', true); $this->executor = Doubles::fromClass('\\Dancras\\Groundwork\\Executor'); $this->runner = new Runner($this->parser, $this->fileSystem, $this->executor); }
public function testCallableArraySyntaxWorksWithMock() { $double = Doubles::fromClass('\\Dummy'); $double->stub('foo', 'abc'); $component = new MockComponent(); $component->mock('foo', array($double, 'foo')); $this->assertSame('abc', $component->whenMethodCalled('foo', array())); }
public function testRunnerWithDummyParser() { $parser = Doubles::fromClass(PHPInputParser::FQCN); $parser->stub('getRunnerParams', array('dummyPath' => 'src/DummyFile.php')); $parser->mock('prepareCompiler', function ($methodName, $arguments) { $arguments[0]->setValue('dummyValue', 'foobar'); }); $runner = new Runner($parser, $this->fileSystem, $this->executor); $runner->run('dummy'); $contents = file_get_contents($this->tempFixturePath . '/src/DummyFile.php'); $this->assertSame('foobar', trim($contents)); }
public function testInterceptOnPartial() { $instance = Doubles::fromClass('\\Doubles\\Test\\Dummy'); $partial = Doubles::partial($instance); $partial->intercept('getFixedValue', function ($methodName, $arguments, $instance) use(&$m, &$a, &$i) { $m = $methodName; $a = $arguments; $i = $instance; return 'intercepted'; }); $this->assertSame('intercepted', $partial->getFixedValue('someArg')); $this->assertSame('getFixedValue', $m); $this->assertEquals(array('someArg'), $a); $this->assertSame($instance, $i); $this->assertSame(0, $instance->spy('getFixedValue')->callCount()); }
public function setUp() { $this->input = Doubles::fromInterface('\\Symfony\\Component\\Console\\Input\\InputInterface'); $this->compiler = Doubles::fromClass(TemplateCompiler::FQCN); $this->parser = new PHPInputParser($this->input); }
public function testOneSharedCallOrderThrowsExceptionWhenCalledMoreThanOnce() { $this->setExpectedException('\\Doubles\\Core\\FailureException'); $spy = Doubles::fromClass('\\SomeClass'); $spy->method(); $spy->method(); $spy->spy('method')->oneSharedCallOrder(); }
public function setUp() { $this->fileSystem = Doubles::fromClass('\\Dancras\\Groundwork\\FileSystem'); $this->templateLoader = new TemplateLoader($this->fileSystem, 'base/path'); }