Exemple #1
0
 private function lintFile($path, array $types)
 {
     if ($path instanceof \SplFileInfo) {
         $path = $path->getPathname();
     }
     $container = $this->getContainer();
     $file = EditorFactory::createEditor()->open($path);
     $violations = $container->get(DocbotExtension::DOCBOT_ID)->lint($file, $types);
     return $this->getReporter()->handle($violations, $file);
 }
 public function testItRemovesCommandDollarSigns()
 {
     $editor = EditorFactory::createEditor();
     $file = $editor->open($this->originalPath);
     $editor->replaceAll($file, '/\\$ /', '');
     $editor->save($file);
     $expected = file_get_contents($this->expectedPath);
     $actual = file_get_contents($this->originalPath);
     $this->assertSame($expected, $actual);
 }
 function it_replaces_all_occurences()
 {
     $editor = EditorFactory::createEditor();
     $filename = __DIR__ . '/../../../../fixtures/sources/life-of-brian.txt';
     $text = $editor->open($filename);
     $expectedFilename = __DIR__ . '/../../../../fixtures/expectations/life-of-brian-replace-all.txt';
     $expectedContent = file_get_contents($expectedFilename);
     $this->execute(array('text' => $text, 'pattern' => self::PATTERN, 'replacement' => self::REPLACEMENT));
     $actualContent = $this->contentFactory->make($text);
     expect($actualContent)->toBe($expectedContent);
 }
 protected function setUp()
 {
     $rootPath = __DIR__ . '/../..';
     $sourceFilename = sprintf(self::APP_KERNEL, $rootPath, 'sources');
     $copyFilename = sprintf(self::APP_KERNEL, $rootPath, 'copies');
     $expectationFilename = sprintf(self::APP_KERNEL, $rootPath, 'expectations');
     $fileCopier = new SymfonyFilesystem();
     $fileCopier->copy($sourceFilename, $copyFilename, true);
     $this->appKernelPath = $copyFilename;
     $this->expectedAppKernelPath = $expectationFilename;
     $this->editor = EditorFactory::createEditor();
 }
 private function defineupSharedServices(ServiceContainer $container)
 {
     $container->define('redaktilo.editor', function () {
         return \Gnugat\Redaktilo\EditorFactory::createEditor();
     });
     $container->define('memio.pretty_printer', function () {
         return \Memio\Memio\Config\Build::prettyPrinter();
     });
     $container->define('memio_spec_gen.event_dispatcher', function (ServiceContainer $container) {
         return new \Symfony\Component\EventDispatcher\EventDispatcher();
     });
     $container->define('memio_spec_gen.command_bus', function (ServiceContainer $container) {
         return new \Memio\SpecGen\CommandBus\CommandBus();
     });
     $container->define('memio_spec_gen.variable_argument_marshaller', function (ServiceContainer $container) {
         return new \Memio\SpecGen\Marshaller\VariableArgumentMarshaller(new \Memio\SpecGen\Marshaller\Service\NameGuesser(), new \Memio\SpecGen\Marshaller\Service\TypeGuesser());
     });
 }
 public function testItAddsAnnotatedRoute()
 {
     $editor = EditorFactory::createEditor();
     $file = $editor->open($this->configPath, true);
     $definitionLine = 'acme_demo:';
     $resourceLine = '    resource: "@AcmeDemoBundle/Controller/"';
     $typeLine = '    type: annotation';
     $prefixLine = '    prefix: /';
     $emptyLine = '';
     $editor->insertAbove($file, $definitionLine);
     $editor->insertBelow($file, $resourceLine);
     $editor->insertBelow($file, $typeLine);
     $editor->insertBelow($file, $prefixLine);
     $editor->insertBelow($file, $emptyLine);
     $editor->save($file);
     $expected = file_get_contents($this->expectedConfigPath);
     $actual = file_get_contents($this->configPath);
     $this->assertSame($expected, $actual);
 }
 function let()
 {
     $this->editor = EditorFactory::createEditor();
 }