Esempio n. 1
0
 public function testWrite()
 {
     $cacheDir = 'cache/dynamo';
     $interface = '\\' . MockInterface::class;
     $className = 'Foo';
     $path = "{$cacheDir}/Tebru/Dynamo/Test/Mock";
     $filename = "{$path}/{$className}.php";
     $filesystem = Mockery::mock(Filesystem::class);
     $classModelTransformer = Mockery::mock(ClassModelTransformer::class);
     $printer = Mockery::mock(PrettyPrinterAbstract::class);
     $classModel = Mockery::mock(ClassModel::class);
     $filesystem->shouldReceive('mkdir')->times(1)->with($path)->andReturnNull();
     $filesystem->shouldReceive('dumpFile')->times(1)->with($filename, 'content');
     $classModelTransformer->shouldReceive('transform')->times(1)->with($classModel)->andReturn(['']);
     $printer->shouldReceive('prettyPrintFile')->times(1)->with([''])->andReturn('content');
     $classModel->shouldReceive('getInterface')->times(1)->withNoArgs()->andReturn($interface);
     $classModel->shouldReceive('getName')->times(1)->withNoArgs()->andReturn($className);
     $cacher = new ClassModelCacher($cacheDir, $filesystem, $classModelTransformer, $printer);
     $cacher->write($classModel);
 }
Esempio n. 2
0
 /**
  * Given an interface name, create a class and write it to disk
  *
  * This method will dispatch events that can be used to set method bodies or modify the class
  *
  * @param string $interfaceName
  * @return $this
  */
 public function createAndWrite($interfaceName)
 {
     $classModel = $this->classModelFactory->make($interfaceName);
     $this->cacher->write($classModel);
     return $this;
 }