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 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); }
private function setUpExpecter($component) { $expecter = Doubles::fromInterface('\\Doubles\\Expectation\\IExpecter'); $expecter->stub('isExpecting', true); $component->addExpecter($expecter); return $expecter; }
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 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 testConstructorIsSkippedForNoConstruct() { $instance = Doubles::noConstruct('\\Doubles\\Test\\Dummy'); $this->assertInstanceOf('\\Doubles\\Test\\Dummy', $instance); $this->assertSame('before', $instance->getConstructedValue()); }
public function setUp() { $this->fileSystem = Doubles::fromClass('\\Dancras\\Groundwork\\FileSystem'); $this->templateLoader = new TemplateLoader($this->fileSystem, 'base/path'); }
public function testConstructorIsNotSkippedOnPartial() { $partial = Doubles::partial(new Dummy()); $this->assertSame(null, $partial->getConstructedValue()); }