public function testItLoadsItemsIntoProcessor()
 {
     $index = $this->createIndex();
     $index->expects($this->once())->method('getHandleIncludes')->with('handle_one')->willReturn(array(Stream::url($this->fileSystem->path() . '/handle_one_file1.php'), Stream::url($this->fileSystem->path() . '/handle_one_file2.php')));
     $processor = $this->createProcessor();
     $processor->expects($this->exactly(3))->method('addItem')->id('addItem')->withConsecutive(array($this->equalTo(new RemoveItem('handle_one_block_one'))), array($this->equalTo(new RemoveItem('handle_one_block_two'))), array($this->equalTo(new RemoveItem('handle_one_block_three'))))->willReturnSelf();
     $processor->expects($this->once())->method('addItemRelation')->after('addItem')->with($this->equalTo(new RemoveItem('handle_one_block_three')), 'handle_one_block_three')->willReturnSelf();
     $this->assertSame($this->loader, $this->loader->loadIntoProcessor('handle_one', $processor, $index));
 }
 protected function setUp()
 {
     $this->fileSystem = Stream::setup();
     $annotations = $this->getAnnotations()['method'];
     if (isset($annotations['sourceFile'])) {
         $fileName = current($annotations['sourceFile']);
         $this->source = new SourceFile(Stream::url($this->fileSystem->path() . '/' . $fileName));
     }
 }
 /**
  * @param EcomDev_LayoutCompiler_Compiler_Metadata[] $metadataObjects
  * @param string $expectedFileContent
  *
  * @dataProvider dataProviderMetadataObjectsToFile
  */
 public function testItSaveMetaDataObjectsToFile($metadataObjects, $expectedFileContent)
 {
     foreach ($metadataObjects as $metadata) {
         $this->index->addMetadata($metadata);
     }
     $path = $this->virtualDirectory->path() . '/somepath';
     $this->index->setSavePath(Stream::url($path));
     $this->assertSame($this->index, $this->index->save(array('test' => 'file')));
     $this->assertStringEqualsFile(Stream::url($path . '/index_test_file.php'), $expectedFileContent);
 }
 public function testItRemovesAnOldSourceFileBeforeReCompiling()
 {
     $parser = $this->createParser('new Node()');
     // Pre-filling item that should be deleted
     mkdir(Stream::url($this->fileSystem->path() . '/compiled'));
     file_put_contents(Stream::url($this->fileSystem->path() . '/compiled/item_id_item2.php'), '<?php test file');
     // Source contains only one handle, so no additional handles should be created
     $source = $this->createSource(array('item1' => array('node' => array_fill(0, 4, array()))));
     $handleFilePaths = array('item1' => Stream::url($this->fileSystem->path() . '/compiled/item_id_item1.php'), 'item2' => Stream::url($this->fileSystem->path() . '/compiled/item_id_item2.php'));
     $metadata = $this->createMetadata($handleFilePaths, true);
     $newMetadata = $this->createMetadata(array_diff_key($handleFilePaths, array('item2' => null)), true);
     $this->metadataFactory->expects($this->once())->method('createFromSource')->with($this->identicalTo($source), array('item1'))->willReturn($newMetadata);
     $compiler = new Compiler($this->getCompilerOptions() + array('parsers' => array('node' => $parser)));
     $this->assertSame($newMetadata, $compiler->compile($source, $metadata));
     $this->assertStringEqualsFile($handleFilePaths['item1'], "<?php \$this->addItem(new Node());\n\$this->addItem(new Node());\n\$this->addItem(new Node());\n\$this->addItem(new Node());");
     $this->assertFileNotExists($handleFilePaths['item2']);
 }
 /**
  * @return array
  */
 public function buildNonS3PathProvider()
 {
     return array(array('/home/testUser/test', 'TestFile', '/home/testUser/test/TestFile'), array('/home/testUser/test', 'TestDir/NestedTestFile', '/home/testUser/test/TestDir/NestedTestFile'), array($this->root->path(), 'testfile1', $this->root->path() . DIRECTORY_SEPARATOR . 'testfile1'));
 }