function it_throws_an_exception_if_settings_schema_does_not_exist(ThemeInterface $theme)
 {
     $theme->getTitle()->willReturn('Candy shop');
     $theme->getName()->willReturn('candy/shop');
     $theme->getPath()->willReturn($this->vfsStream->url());
     $this->shouldThrow(new \InvalidArgumentException(sprintf('Could not find settings schema of theme "Candy shop" (candy/shop) in file "%s"', $this->vfsStream->url() . '/Settings.php')))->during('getSchema', [$theme]);
 }
 public function testCreate_WhenPatternHasLastOnFile_ThrowsException()
 {
     vfsStream::newFile('file.csv')->at($this->root);
     $pathToFile = $this->root->url() . '/file.csv';
     $this->setExpectedException('\\InvalidArgumentException');
     $this->getFileNameGenerator($pathToFile . ':last')->getGeneratedFileName();
 }
 public function testConstruct()
 {
     $this->assertFileExists($this->configDir->url() . DIRECTORY_SEPARATOR . 'test');
     unset($configHandler);
     new ConfigFileHandler('test-process', $this->configDirPath);
     $this->assertEquals(['root' => ['test' => []]], vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure());
 }
예제 #4
0
 public function setUp()
 {
     $this->rootDir = new vfsStreamDirectory('queries');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->rootDir);
     $this->loader = new FilesystemQueryLoader($this->rootDir->url());
 }
 /**
  * @test
  */
 public function shouldUpdateVersionInEmConf()
 {
     $service = new EmConfService($this->root->url(), 'extension_manager');
     $service->updateVersion('47.11.4711');
     $service->write();
     $this->assertRegExp('~\'version\' => \'47\\.11\\.4711\'~', $this->emConf->getContent());
 }
 public function testNonExistent()
 {
     $url = $this->_root->url() . '/test';
     $validator = new DirectoryWritable();
     $this->assertFalse($validator->isValid($url));
     $this->assertEquals(array(DirectoryWritable::DIRECTORY => "'{$url}' ist kein Verzeichnis oder nicht zugänglich"), $validator->getMessages());
 }
 /**
  * @expectedException RuntimeException
  */
 public function testShouldThrowExceptionWhenDeletionNotPermitted()
 {
     $this->root->chmod(0555);
     $this->root->getChild('testfile2')->chmod(0555);
     $localDelete = new DefaultDelete($this->root->url() . '/testfile2');
     $localDelete->execute();
 }
예제 #8
0
 public function testNonExistent()
 {
     $url = $this->_root->url() . '/test';
     $validator = new FileReadable();
     $this->assertFalse($validator->isValid($url));
     $this->assertEquals(array(FileReadable::FILE => "'{$url}' ist keine Datei oder nicht zugänglich"), $validator->getMessages());
 }
예제 #9
0
 /**
  */
 public function testFustyRequest_ValidateUpload()
 {
     //// Setup test
     $firstChunk = vfsStream::newFile('temp_file');
     $firstChunk->setContent('1234567890');
     $this->vfs->addChild($firstChunk);
     $fileInfo = new \ArrayObject(array('size' => 10, 'error' => UPLOAD_ERR_OK, 'tmp_name' => $firstChunk->url()));
     $request = new \ArrayObject(array('flowIdentifier' => '13632-prettifyjs', 'flowFilename' => 'prettify.js', 'flowRelativePath' => 'home/prettify.js'));
     $fustyRequest = new FustyRequest($request, $fileInfo);
     $config = new Config();
     $config->setTempDir($this->vfs->url());
     /** @var File $file */
     $file = $this->getMock('Flow\\File', array('_move_uploaded_file'), array($config, $fustyRequest));
     /** @noinspection PhpUndefinedMethodInspection */
     $file->expects($this->once())->method('_move_uploaded_file')->will($this->returnCallback(function ($filename, $destination) {
         return rename($filename, $destination);
     }));
     //// Actual test
     $this->assertTrue($file->validateChunk());
     $this->assertFalse($file->validateFile());
     $this->assertTrue($file->saveChunk());
     $this->assertTrue($file->validateFile());
     $path = $this->vfs->url() . DIRECTORY_SEPARATOR . 'new';
     $this->assertTrue($file->save($path));
     $this->assertEquals(10, filesize($path));
 }
 public function testCreateTmpDir()
 {
     $workingDirectory = $this->workingDirectoryFactory->createTmpDir(array(), array());
     $workingDirectoryPath = $workingDirectory->getPath();
     $this->assertNotEquals($this->storageDir->url(), $workingDirectoryPath);
     $this->assertEquals($this->storageDir->url(), dirname($workingDirectoryPath));
     $this->assertNotEmpty(basename($workingDirectoryPath));
 }
 protected function setUp()
 {
     $this->root = new vfsStreamDirectory('test');
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot($this->root);
     $this->responder = new StaticHtmlFileResponder($this->root->url(), 'file');
     $this->response = new Response();
 }
 /**
  * @param $fileContent
  * @param $expectedMetadataObjects
  * @param $expectedMetadataHandleObjects
  * 
  * @dataProvider dataProviderMetadataObjectsFromFile
  */
 public function testItLoadsMetaDataObjectsFromFile($fileContent, $expectedMetadataObjects, $expectedMetadataHandleObjects)
 {
     Stream::create(array('index_test_file.php' => $fileContent), $this->virtualDirectory);
     $this->index->setSavePath($this->virtualDirectory->url());
     $this->assertTrue($this->index->load(array('test' => 'file')));
     $this->assertAttributeEquals($expectedMetadataObjects, 'metadata', $this->index);
     $this->assertAttributeEquals($expectedMetadataHandleObjects, 'metadataByHandle', $this->index);
 }
예제 #13
0
 protected function pathToUrl($path = '')
 {
     //@todo Consider adding hasChild() test and throw exception if test fails?
     if ($this->root->hasChild(ltrim($path, '/'))) {
         return $this->root->getChild(ltrim($path, '/'))->url();
     }
     return $this->root->url() . $path;
 }
예제 #14
0
 protected function createTestProject()
 {
     $testDir = self::$tmpName = tempnam(self::$root->url(), '');
     unlink($testDir);
     mkdir($testDir);
     file_put_contents($testDir . '/' . Config::PLATFORM_CONFIG, 'name: phpunit');
     chdir($testDir);
 }
예제 #15
0
 public function testOutputDirNotFound()
 {
     $dir = $this->output_dir->url('thumbs');
     $service = new ImageService($this->imanee, $this->source_dir, $dir . '/test', new Filesystem());
     // test a valid resource
     $thumbnail = $service->thumbnail('valid.jpg', 100, 100, false);
     $this->assertContains('-100x100.jpeg', $thumbnail);
 }
예제 #16
0
 public function test_invoke_generator_with_original_content_if_argument_is_passed()
 {
     $original_file = $this->root->url() . '/phpunit.xml.dist';
     $original_content = '<phpunit colors="true"><listeners><listener class="MyListener"></listener></listeners></phpunit>';
     file_put_contents($original_file, $original_content);
     $this->expectOutputString($this->path("Creating .smartrunner/config.php.\n" . "Creating .smartrunner/phpunit.xml.dist.\n"));
     $this->phpunit_config_generator->generate($original_content, '..')->shouldBeCalled();
     $this->command->run([$original_file]);
 }
 public function setUp()
 {
     $this->mockLockDirectory = vfsStream::setup('LockPath');
     $this->mockLockFile = vfsStream::newFile(md5(FLOW_PATH_ROOT) . '_Flow.lock')->at($this->mockLockDirectory);
     $this->mockLockFlagFile = vfsStream::newFile(md5(FLOW_PATH_ROOT) . '_FlowIsLocked')->at($this->mockLockDirectory);
     $this->lockManager = $this->getMockBuilder(LockManager::class)->setMethods(['getLockPath', 'doExit'])->disableOriginalConstructor()->getMock();
     $this->lockManager->expects($this->atLeastOnce())->method('getLockPath')->will($this->returnValue($this->mockLockDirectory->url() . '/'));
     $this->lockManager->__construct();
 }
 /**
  * @test
  */
 public function write()
 {
     $messages = 'Messages will be here';
     $printer = $this->createPrinter($this->validRoot->url());
     $printer->write($messages);
     $expectedStructure = vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure();
     // Assert that string was written
     $this->assertEquals(['root' => ['test.json' => $messages]], $expectedStructure);
 }
예제 #19
0
 /**
  * @Given /^the model generator for namespace "([^"]*)"$/
  */
 public function theModelGeneratorForNamespace($namespace)
 {
     if (isset($this->vfs)) {
         unset($this->vfs);
     }
     $this->vfs = vfsStream::setup('root');
     spl_autoload_register([$this, 'autoload'], false);
     $this->generator = new ModelGenerator($this->vfs->url(), $namespace);
 }
예제 #20
0
 public function testNotFoundThumbnail()
 {
     $service = new ImageService($this->imanee, $this->source_dir, $this->output_dir->url('thumbs'), new Filesystem());
     // test a not-found resource
     try {
         $service->thumbnail('not-found.jpg', 100, 100, false);
     } catch (ImageNotFoundException $e) {
     }
     $this->assertNotEmpty($e);
 }
 /**
  * @test
  */
 public function shouldUpdateVersionNumberVerbose()
 {
     /** @var EmConfCommand $gitCommand */
     $application = new Application();
     $application->add(new EmConfCommand());
     $command = $application->find('emconf');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'path' => $this->root->url(), 'extension' => 'extension_manager', '--version-number' => '0.0.2'), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE));
     $this->assertRegExp('~\\.\\.\\.updating version to "0\\.0\\.2"~', $commandTester->getDisplay());
 }
예제 #22
0
 protected function getNewTmpFolder($name)
 {
     if ('true' === getenv('GUSH_USE_FS')) {
         $path = $this->tmpFs . '/' . $name . ++self::$dirCounter . microtime(true);
     } else {
         $path = $this->tmpFs->url() . '/' . $name;
     }
     $this->assertFileNotExists($path);
     mkdir($path);
     return $path;
 }
예제 #23
0
 /**
  * @covers ::updateAddressFormats
  */
 public function testUpdateAddressFormatsStoresAllData()
 {
     $testAdapter = new HttpTestAdapter();
     $testAdapter->setResponse([(new HttpResponse())->setContent('{"countries": "US~UK"}'), (new HttpResponse())->setContent('{"name": "US"}'), (new HttpResponse())->setContent('{"name": "UK"}'), (new HttpResponse())->setContent('{"name": "ZZ"}')]);
     $httpClient = new HttpClient();
     $httpClient->setAdapter($testAdapter);
     $maintenanceService = new MaintenanceService($this->options, $httpClient);
     $maintenanceService->updateAddressFormats();
     $this->assertSame(['US', 'UK'], include $this->root->url() . '/country-codes.php');
     $this->assertSame('{"name": "US"}', file_get_contents($this->root->url() . '/US.json'));
     $this->assertSame('{"name": "UK"}', file_get_contents($this->root->url() . '/UK.json'));
     $this->assertSame('{"name": "ZZ"}', file_get_contents($this->root->url() . '/ZZ.json'));
 }
예제 #24
0
 /**
  * Mocks an entire module, called foo, in a virtual file system.
  */
 public function setUp()
 {
     $this->info = $this->getAnnotations();
     $this->dir = $this->mockModule('foo');
     $this->mockContainer();
     $this->mockTranslator();
     $this->mockLogger();
     $this->initDB();
     // At the time of this writing, Target will pull the indexer manager out
     // of the container right away, so let's mock it.
     $indexers = $this->getMock('\\Drupal\\Component\\Plugin\\PluginManagerInterface');
     $this->container->set('plugin.manager.drupalmoduleupgrader.indexer', $indexers);
     $this->target = new Target($this->dir->url(), $this->container);
 }
예제 #25
0
 protected function setUp()
 {
     parent::setUp();
     $this->applicationPath = vfsStream::setup('application_path');
     $this->input = $this->getMock(InputInterface::class);
     $this->output = $this->getMock(OutputInterface::class);
     $this->pathHelper = $this->getMock(PathHelper::class);
     $this->questionHelper = $this->getMock(TravisCiQuestionHelper::class, [], [], '', false);
     $this->configBuilder = $this->getMock(ConfigBuilder::class, [], [], '', false);
     $this->configWriter = new ConfigWriter();
     $this->configPath = sprintf('%s/.travis.yml', $this->applicationPath->url());
     $this->pathHelper->method('getPath')->willReturn($this->configPath);
     $this->sut = new TravisCiCommand($this->questionHelper, $this->configBuilder, $this->configWriter);
     $this->sut->setHelperSet(new HelperSet(['path' => $this->pathHelper]));
 }
 public function testRoutingFile()
 {
     $routingConfiguration = ['fake' => ['path' => '/fake', 'defaults' => ['_controller' => null]]];
     $routingFile = $this->root->url() . '/routing.yml';
     $handle = fopen($routingFile, 'w');
     fwrite($handle, Yaml::dump($routingConfiguration));
     fclose($handle);
     $app = new Application();
     $app->register(new RoutingServiceProvider(), ['router.resource' => $routingFile]);
     $app->boot();
     /** @var \Symfony\Component\Routing\RouterInterface $router */
     $router = $app['router'];
     $this->assertCount(1, $router->getRouteCollection());
     $this->assertSame('/fake', $router->generate('fake'));
 }
 public function testGenerateWithoutUsingNamespace()
 {
     $manager = $this->getManager();
     $manager->configure($this->className, $this->indention, $this->fileSystem->url(), null, $this->extends);
     $manager->generate();
     $filePath = $this->fileSystem->url() . '/' . $this->className . '.php';
     $fileContent = file_get_contents($filePath);
     $this->assertTrue(file_exists($filePath));
     $this->assertContains('class ' . $this->className, $fileContent);
     $this->assertContains('extends ' . $this->extends, $fileContent);
     $this->assertContains($this->indention . 'public function ', $fileContent);
     $this->assertNotContains('namespace', $fileContent);
     $this->assertNotContains('use Propel;', $fileContent);
     $this->assertNotContains('use PDO;', $fileContent);
 }
예제 #28
0
 /**
  * @covers ::getCountryCodes
  */
 public function testGetCountryCodesOnlyAccessesFilesystemOnce()
 {
     $addressService = new AddressService($this->options);
     $this->assertSame(['US', 'UK', 'DE', 'FR'], $addressService->getCountryCodes());
     $this->root->removeChild($this->root->url() . '/country-codes.php');
     $this->assertSame(['US', 'UK', 'DE', 'FR'], $addressService->getCountryCodes());
 }
예제 #29
0
 public function testAllDirectories()
 {
     $this->root->addChild(new vfsStreamDirectory('tmp'));
     $this->root->addChild(new vfsStreamDirectory('tmp2'));
     $arr = $this->files->allDirectories($this->root->url());
     $this->assertInstanceOf(SplFileInfo::class, $arr[0]);
 }
예제 #30
0
 /**
  * @test
  * it should map wp-admin to wp-admin/index.php
  * @dataProvider adminUris
  */
 public function it_should_map_wp_admin_to_wp_admin_index_php($uri)
 {
     $sut = $this->make_instance();
     $indexFile = $sut->getIndexForUri($uri);
     $expected = $this->root->url() . '/wp-admin/index.php';
     $this->assertEquals($expected, $indexFile);
 }