public function testPlay整形クラスをプライオリティー順に実行() { $contents = 'Test Data'; $formatted1 = 'Change Data'; $formatted2 = 'Final Data'; $transformerMock1 = Mockery::mock('Comja\\Services\\Transformers\\Transformers\\TransformerInterface'); $transformerMock1->shouldReceive('getPriority')->once()->andReturn(1000); $transformerMock1->shouldReceive('transform')->once()->with($contents)->andReturn($formatted1); $transformerMock2 = Mockery::mock('Comja\\Services\\Transformers\\Transformers\\TransformerInterface'); $transformerMock2->shouldReceive('getPriority')->once()->andReturn(2000); $transformerMock2->shouldReceive('transform')->once()->with($formatted1)->andReturn($formatted2); $box = new ToyBox(); $box->push($transformerMock1); $box->push($transformerMock2); $this->assertEquals($formatted2, $box->play($contents)); }
/** * 指定されたオプションに従い * 新規作成した言語ファイルの変換を行う */ public function formatNewFiles() { $cwd = $this->file->getCurrentDir(); $files = $this->file->globFiles($cwd . '/resources/lang/ja', '*'); foreach ($files as $targetFile) { // $targetFileは絶対パス $translation = $this->langRepo->get($targetFile); if ($translation !== false) { $this->box['翻訳']->setTranslations($translation); } // 変換 $contens = $this->file->getContents($targetFile); $converted = $this->box->play($contens); $this->file->putContents($targetFile, $converted); } }