예제 #1
0
 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);
 }
예제 #2
0
 public function testFluentInterface()
 {
     $double = Doubles::fromClass('\\SomeClass');
     $double->stub('foo', 'bar')->stub('hello', 'world');
     $this->assertSame('bar', $double->foo());
     $this->assertSame('world', $double->hello());
 }
예제 #3
0
 public function testDoesNothingWhenMethodExpected()
 {
     $expectationComponent = Doubles::fromClass('\\Doubles\\Expectation\\ExpectationComponent');
     $expectationComponent->stub('isMethodExpected', true);
     $component = new PartialComponent($expectationComponent);
     $this->assertNull($component->whenMethodCalled('foo', array()));
 }
예제 #4
0
 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);
 }
예제 #5
0
 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()));
 }
예제 #6
0
 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));
 }
예제 #7
0
 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());
 }
예제 #8
0
 public function setUp()
 {
     $this->input = Doubles::fromInterface('\\Symfony\\Component\\Console\\Input\\InputInterface');
     $this->compiler = Doubles::fromClass(TemplateCompiler::FQCN);
     $this->parser = new PHPInputParser($this->input);
 }
예제 #9
0
파일: SpyTest.php 프로젝트: dancras/doubles
 public function testOneSharedCallOrderThrowsExceptionWhenCalledMoreThanOnce()
 {
     $this->setExpectedException('\\Doubles\\Core\\FailureException');
     $spy = Doubles::fromClass('\\SomeClass');
     $spy->method();
     $spy->method();
     $spy->spy('method')->oneSharedCallOrder();
 }
예제 #10
0
 public function setUp()
 {
     $this->fileSystem = Doubles::fromClass('\\Dancras\\Groundwork\\FileSystem');
     $this->templateLoader = new TemplateLoader($this->fileSystem, 'base/path');
 }