Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Esempio n. 1
0
 /**
  * Adds a style.
  *
  * @param Style $style The style to add.
  *
  * @throws LogicException If the tag of the style is not set.
  */
 public function add(Style $style)
 {
     if (!$style->getTag()) {
         throw new LogicException('The tag of a style added to the style set must be set.');
     }
     $this->styles[$style->getTag()] = $style;
 }
 /**
  * {@inheritdoc}
  */
 protected function configure()
 {
     $this->setEventDispatcher(new EventDispatcher());
     parent::configure();
     $this->setName('dancer')->setDisplayName('SkeletonDancer')->addOption('project-directory', null, Option::OPTIONAL_VALUE, 'The root directory of the project, this is where the ".dancer" directory is located. ' . 'When omitted the directory is automatically searched by the first occurrence of the ".dancer" directory
             in the parent directory structure, and falls back to the current working directory.')->addOption('config-file', null, Option::OPTIONAL_VALUE | Option::NULLABLE, 'Configuration file to load. When omitted the file `.dancer.yml` is automatically searched in the parent directory structure. Pass "null" to disable', '')->addOption('overwrite', null, Option::REQUIRED_VALUE, 'Default operation for existing files: abort, skip, force, ask, backup')->setVersion(self::VERSION)->setDebug('true' === getenv('SKELETON_DANCER_DEBUG'))->addStyle(Style::tag('good')->fgGreen())->addStyle(Style::tag('bad')->fgRed())->addStyle(Style::tag('warn')->fgYellow())->addStyle(Style::tag('hl')->fgGreen());
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, function (PreHandleEvent $event) {
         // Set-up the IO for the Symfony Helper classes.
         if (!isset($this->container['console_io'])) {
             $io = $event->getIO();
             $args = $event->getArgs();
             $input = new ArgsInput($args->getRawArgs(), $args);
             $input->setInteractive($io->isInteractive());
             $this->container['console_io'] = $io;
             $this->container['console_args'] = $args;
             $this->container['sf.console_input'] = $input;
             $this->container['sf.console_output'] = new IOOutput($io);
         }
     });
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new ProjectDirectorySetupListener($this->container));
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new AutoLoadingSetupListener($this->container));
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new ExpressionFunctionsProviderSetupListener($this->container));
     $this->beginCommand('generate')->setDescription('Generates a new skeleton structure in the current directory')->addArgument('profile', Argument::OPTIONAL, 'The name of the profile')->addOption('all', null, Option::BOOLEAN, 'Ask all questions (including optional)')->addOption('dry-run', null, Option::BOOLEAN, 'Show what would have been executed, without actually executing')->setHandler(function () {
         return new Handler\GenerateCommandHandler($this->container['style'], $this->container['config'], $this->container['profile_config_resolver'], $this->container['answers_set_factory']);
     })->end()->beginCommand('profile')->setDescription('Manage the profiles of your project')->setHandler(function () {
         return new Handler\ProfileCommandHandler($this->container['style'], $this->container['profile_config_resolver'], $this->container['config']);
     })->beginSubCommand('list')->setHandlerMethod('handleList')->markDefault()->end()->beginSubCommand('show')->addArgument('name', Argument::OPTIONAL, 'The name of the profile')->setHandlerMethod('handleShow')->end()->end();
 }
Esempio n. 3
0
 /**
  * A borderless style.
  *
  * @return TableStyle The style.
  */
 public static function borderless()
 {
     if (!self::$borderless) {
         $borderStyle = BorderStyle::none();
         $borderStyle->setLineVCChar('  ');
         self::$borderless = new static();
         self::$borderless->setBorderStyle($borderStyle);
         self::$borderless->setHeaderCellStyle(Style::noTag()->bold());
     }
     return clone self::$borderless;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 protected function configure()
 {
     // Make sure the console and Puli use the same event dispatcher so that
     // Puli plugins can listen to the console events.
     // Add the dispatcher before parent::configure() so that the parent
     // listeners don't get overwritten.
     $this->setEventDispatcher($this->puli->getEventDispatcher());
     parent::configure();
     $puli = $this->puli;
     $this->setName('puli')->setDisplayName('Puli')->setVersion(self::VERSION)->setDebug('@pack' . 'age_version@' === self::VERSION)->addStyle(Style::tag('good')->fgGreen())->addStyle(Style::tag('bad')->fgRed());
     $this->beginCommand('bind')->setDescription('Bind resources to binding types')->setHandler(function () use($puli) {
         return new BindCommandHandler($puli->getDiscoveryManager(), $puli->getPackageManager()->getPackages());
     })->beginOptionCommand('add')->markAnonymous()->addArgument('query', Argument::REQUIRED, 'A query for resources')->addArgument('type', Argument::REQUIRED, 'The name of the binding type')->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', 'glob', 'language')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value')->addOption('force', 'f', Option::NO_VALUE, 'Add binding even if the binding type does not exist')->setHandlerMethod('handleAdd')->end()->beginOptionCommand('list')->markDefault()->addOption('root', null, Option::NO_VALUE, 'Show bindings of the root package')->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show bindings of a package', null, 'package')->addOption('all', 'a', Option::NO_VALUE, 'Show bindings of all packages')->addOption('enabled', null, Option::NO_VALUE, 'Show enabled bindings')->addOption('disabled', null, Option::NO_VALUE, 'Show disabled bindings')->addOption('undecided', null, Option::NO_VALUE, 'Show bindings that are neither enabled nor disabled')->addOption('type-not-found', null, Option::NO_VALUE, 'Show bindings whose type is not found')->addOption('type-not-enabled', null, Option::NO_VALUE, 'Show bindings whose type is not enabled')->addOption('ignored', null, Option::NO_VALUE, 'Show bindings whose type is disabled')->addOption('invalid', null, Option::NO_VALUE, 'Show bindings with invalid parameters')->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', 'glob', 'language')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value')->setHandlerMethod('handleList')->end()->beginOptionCommand('update', 'u')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the updated binding')->addOption('query', null, Option::REQUIRED_VALUE, 'A query for resources')->addOption('type', null, Option::REQUIRED_VALUE, 'The name of the binding type')->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the resource query', null, 'language')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A binding parameter in the form <key>=<value>', null, 'key=value')->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Unset a binding parameter', null, 'key')->addOption('force', 'f', Option::NO_VALUE, 'Update binding even if the binding type does not exist')->setHandlerMethod('handleUpdate')->end()->beginOptionCommand('delete', 'd')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the removed binding')->setHandlerMethod('handleDelete')->end()->beginOptionCommand('enable')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the enabled binding')->setHandlerMethod('handleEnable')->end()->beginOptionCommand('disable')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the disabled binding')->setHandlerMethod('handleDisable')->end()->end();
     $this->beginCommand('build')->setDescription('Build the resource repository/discovery')->addArgument('target', Argument::OPTIONAL, 'The build target. One of "repository", "discovery", "factory" and "all"', 'all')->setHandler(function () use($puli) {
         return new BuildCommandHandler($puli->getRepositoryManager(), $puli->getDiscoveryManager(), $puli->getFactoryManager());
     })->end();
     $this->beginCommand('config')->setDescription('Display and modify configuration values')->setHandler(function () use($puli) {
         return new ConfigCommandHandler($puli->getRootPackageFileManager());
     })->beginSubCommand('list')->markDefault()->addOption('parsed', null, Option::NO_VALUE, 'Replace placeholders by their values in the output')->setHandlerMethod('handleList')->end()->beginSubCommand('show')->markAnonymous()->addArgument('key', Argument::REQUIRED, 'The configuration key to show. May contain wildcards ("*")')->addOption('parsed', null, Option::NO_VALUE, 'Replace placeholders by their values in the output')->setHandlerMethod('handleShow')->end()->beginSubCommand('set')->markAnonymous()->addArgument('key', Argument::REQUIRED, 'The modified configuration key')->addArgument('value', Argument::REQUIRED, 'The value to set for the configuration key')->setHandlerMethod('handleSet')->end()->beginOptionCommand('reset', 'r')->addArgument('key', Argument::REQUIRED, 'The configuration key(s) to reset. May contain wildcards ("*")')->setHandlerMethod('handleReset')->end()->end();
     $this->beginCommand('find')->setDescription('Find resources by different criteria')->addOption('path', null, Option::REQUIRED_VALUE, 'The resource path. May contain the wildcard "*"')->addOption('name', null, Option::REQUIRED_VALUE, 'The resource filename. May contain the wildcard "*"')->addOption('class', null, Option::REQUIRED_VALUE, 'The short name of a resource class')->addOption('type', null, Option::REQUIRED_VALUE, 'The name of a binding type')->addOption('language', null, Option::REQUIRED_VALUE, 'The language of the query passed with --path', 'glob')->setHandler(function () use($puli) {
         return new FindCommandHandler($puli->getRepository(), $puli->getDiscovery());
     })->end();
     $this->beginCommand('installer')->setDescription('Manage the installers used to install web resources')->setHandler(function () use($puli) {
         return new InstallerCommandHandler($puli->getInstallerManager());
     })->beginOptionCommand('list')->markDefault()->addOption('long', 'l', Option::NO_VALUE, 'Print the fully-qualified class name')->setHandlerMethod('handleList')->end()->beginOptionCommand('add', 'a')->addArgument('name', Argument::REQUIRED, 'The name of the installer')->addArgument('class', Argument::REQUIRED, 'The fully-qualified class name of the installer')->addOption('description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'The description of the installer')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional installer parameters')->setHandlerMethod('handleAdd')->end()->beginOptionCommand('delete', 'd')->addArgument('name', Argument::REQUIRED, 'The name of the installer to remove')->setHandlerMethod('handleDelete')->end()->end();
     $this->beginCommand('ls')->setDescription('List the children of a resource in the repository')->addArgument('path', Argument::OPTIONAL, 'The path of a resource', '/')->addOption('long', 'l', Option::NO_VALUE, 'Print more information about each child')->setHandler(function () use($puli) {
         return new LsCommandHandler($puli->getRepository());
     })->end();
     $this->beginCommand('map')->setDescription('Display and change path mappings')->setHandler(function () use($puli) {
         return new MapCommandHandler($puli->getRepositoryManager(), $puli->getPackageManager()->getPackages());
     })->beginOptionCommand('add')->markAnonymous()->addArgument('path', Argument::REQUIRED)->addArgument('file', Argument::REQUIRED | Argument::MULTI_VALUED)->addOption('force', 'f', Option::NO_VALUE, 'Map even if the target path does not exist')->setHandlerMethod('handleAdd')->end()->beginOptionCommand('list')->markDefault()->addOption('root', null, Option::NO_VALUE, 'Show mappings of the root package')->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show mappings of a package', null, 'package')->addOption('all', 'a', Option::NO_VALUE, 'Show mappings of all packages')->addOption('enabled', null, Option::NO_VALUE, 'Show enabled mappings')->addOption('not-found', null, Option::NO_VALUE, 'Show mappings whose referenced paths do not exist')->addOption('conflict', null, Option::NO_VALUE, 'Show conflicting mappings')->setHandlerMethod('handleList')->end()->beginOptionCommand('update', 'u')->addArgument('path', Argument::REQUIRED)->addOption('add', 'a', Option::REQUIRED_VALUE | Option::MULTI_VALUED | Option::PREFER_LONG_NAME, 'Add a file to the path mapping', null, 'file')->addOption('remove', 'r', Option::REQUIRED_VALUE | Option::MULTI_VALUED | Option::PREFER_LONG_NAME, 'Remove a file from the path mapping', null, 'file')->addOption('force', 'f', Option::NO_VALUE, 'Map even if the target path does not exist')->setHandlerMethod('handleUpdate')->end()->beginOptionCommand('delete', 'd')->addArgument('path', Argument::REQUIRED)->addArgument('file', Argument::OPTIONAL)->setHandlerMethod('handleDelete')->end()->end();
     $this->beginCommand('package')->setDescription('Display the installed packages')->setHandler(function () use($puli) {
         return new PackageCommandHandler($puli->getPackageManager());
     })->beginOptionCommand('add', 'a')->addArgument('path', Argument::REQUIRED, 'The path to the package')->addArgument('name', Argument::OPTIONAL, 'The name of the package. Taken from puli.json if not passed.')->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the installer', InstallInfo::DEFAULT_INSTALLER_NAME)->setHandlerMethod('handleAdd')->end()->beginOptionCommand('list')->markDefault()->addOption('installer', null, Option::REQUIRED_VALUE, 'Show packages installed by a specific installer')->addOption('enabled', null, Option::NO_VALUE, 'Show enabled packages')->addOption('not-found', null, Option::NO_VALUE, 'Show packages that could not be found')->addOption('not-loadable', null, Option::NO_VALUE, 'Show packages that could not be loaded')->addOption('format', null, Option::REQUIRED_VALUE, 'The format of the output. You can use the variables %name%, %install_path%, %installer% and %state% in the format string', null, 'format')->setHandlerMethod('handleList')->end()->beginOptionCommand('rename')->addArgument('name', Argument::REQUIRED, 'The name of the package')->addArgument('new-name', Argument::REQUIRED, 'The new name of the package')->setHandlerMethod('handleRename')->end()->beginOptionCommand('delete', 'd')->addArgument('name', Argument::REQUIRED, 'The name of the package')->setHandlerMethod('handleDelete')->end()->beginOptionCommand('clean')->setHandlerMethod('handleClean')->end()->end();
     $this->beginCommand('plugin')->setDescription('Manage the installed Puli plugins')->setHandler(function () use($puli) {
         return new PluginCommandHandler($puli->getRootPackageFileManager());
     })->beginOptionCommand('install', 'i')->addArgument('class', Argument::REQUIRED, 'The fully-qualified plugin class name')->setHandlerMethod('handleInstall')->end()->beginOptionCommand('list')->markDefault()->setHandlerMethod('handleList')->end()->beginOptionCommand('delete', 'd')->addArgument('class', Argument::REQUIRED, 'The fully-qualified plugin class name')->setHandlerMethod('handleDelete')->end()->end();
     $this->beginCommand('publish')->setDescription('Manage public resources')->setHandler(function () use($puli) {
         return new PublishCommandHandler($puli->getAssetManager(), $puli->getInstallationManager(), $puli->getServerManager());
     })->beginOptionCommand('add')->markAnonymous()->addArgument('path', Argument::REQUIRED, 'The resource path')->addArgument('server', Argument::REQUIRED, 'The resource path')->addArgument('server-path', Argument::OPTIONAL, 'The path in the document root of the server', '/')->addOption('force', 'f', Option::NO_VALUE, 'Map even if the server does not exist')->setHandlerMethod('handleAdd')->end()->beginOptionCommand('update', 'u')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the mapping')->addOption('path', null, Option::REQUIRED_VALUE, 'The resource path')->addOption('server', 's', Option::REQUIRED_VALUE | Option::PREFER_LONG_NAME, 'The name of the target server')->addOption('server-path', null, Option::REQUIRED_VALUE, 'The path in the document root')->addOption('force', 'f', Option::NO_VALUE, 'Update even if the server does not exist')->setHandlerMethod('handleUpdate')->end()->beginOptionCommand('delete', 'd')->addArgument('uuid', Argument::REQUIRED, 'The UUID (prefix) of the mapping')->setHandlerMethod('handleDelete')->end()->beginOptionCommand('list', 'l')->markDefault()->setHandlerMethod('handleList')->end()->beginOptionCommand('install')->addArgument('server', Argument::OPTIONAL, 'The server to install. By default, all servers are installed')->setHandlerMethod('handleInstall')->end()->end();
     $this->beginCommand('self-update')->setDescription('Update Puli to the latest version.')->addOption('stable', null, Option::NO_VALUE, 'Update to the latest stable version')->addOption('unstable', null, Option::NO_VALUE, 'Update to the latest unstable version')->setHandler(function () {
         return new SelfUpdateCommandHandler();
     })->enableIf('phar://' === substr(__DIR__, 0, 7))->end();
     $this->beginCommand('server')->setDescription('Manage your asset servers')->setHandler(function () use($puli) {
         return new ServerCommandHandler($puli->getServerManager());
     })->beginOptionCommand('list')->markDefault()->setHandlerMethod('handleList')->end()->beginOptionCommand('add', 'a')->addArgument('name', Argument::REQUIRED, 'The name of the added server')->addArgument('document-root', Argument::REQUIRED, 'The document root of the server')->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the used installer', 'symlink')->addOption('url-format', null, Option::REQUIRED_VALUE, 'The format of the generated resource URLs', Server::DEFAULT_URL_FORMAT)->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional parameters required by the resource installer')->setHandlerMethod('handleAdd')->end()->beginOptionCommand('update', 'u')->addArgument('name', Argument::REQUIRED, 'The name of the updated server')->addOption('document-root', null, Option::REQUIRED_VALUE, 'The document root of the server')->addOption('installer', null, Option::REQUIRED_VALUE, 'The name of the used installer', 'symlink')->addOption('url-format', null, Option::REQUIRED_VALUE, 'The format of the generated resource URLs', Server::DEFAULT_URL_FORMAT)->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Additional parameters required by the resource installer')->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Parameters to remove from the server')->setHandlerMethod('handleUpdate')->end()->beginOptionCommand('delete', 'd')->addArgument('name', Argument::REQUIRED, 'The name of the server to remove')->setHandlerMethod('handleDelete')->end()->end();
     $this->beginCommand('tree')->setDescription('Print the contents of a resource as tree')->addArgument('path', Argument::OPTIONAL, 'The path of a resource', '/')->setHandler(function () use($puli) {
         return new TreeCommandHandler($puli->getRepository());
     })->end();
     $this->beginCommand('type')->setDescription('Display and change binding types')->setHandler(function () use($puli) {
         return new TypeCommandHandler($puli->getDiscoveryManager(), $puli->getPackageManager()->getPackages());
     })->beginOptionCommand('define')->addArgument('name', Argument::REQUIRED, 'The name of the binding type')->addOption('description', null, Option::REQUIRED_VALUE, 'A human-readable description of the type')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A type parameter in the form <key> or <key>=<value>', null, 'key=value')->addOption('param-description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A human-readable parameter description in the form <key>=<description>', null, 'key=description')->addOption('force', 'f', Option::NO_VALUE, 'Add type even if another type exists with the same name')->setHandlerMethod('handleDefine')->end()->beginSubCommand('list')->markDefault()->addOption('root', null, Option::NO_VALUE, 'Show types of the root package')->addOption('package', 'p', Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Show types of a package', null, 'package')->addOption('all', 'a', Option::NO_VALUE, 'Show types of all packages')->addOption('enabled', null, Option::NO_VALUE, 'Show enabled types')->addOption('duplicate', null, Option::NO_VALUE, 'Show duplicate types')->setHandlerMethod('handleList')->end()->beginOptionCommand('update')->addArgument('name', Argument::REQUIRED, 'The name of the binding type')->addOption('description', null, Option::REQUIRED_VALUE, 'A human-readable description of the type')->addOption('param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A type parameter in the form <key> or <key>=<value>', null, 'key=value')->addOption('param-description', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'A human-readable parameter description in the form <key>=<description>', null, 'key=description')->addOption('unset-param', null, Option::REQUIRED_VALUE | Option::MULTI_VALUED, 'Unset a type parameter', null, 'key')->setHandlerMethod('handleUpdate')->end()->beginOptionCommand('delete', 'd')->addArgument('name', Argument::REQUIRED, 'The name of the binding type')->setHandlerMethod('handleDelete')->end()->end();
 }
Esempio n. 5
0
 /**
  * Converts a {@link Style} instance to an {@link OutputFormatterStyle}.
  *
  * @param Style $style The style to convert.
  *
  * @return OutputFormatterStyle The converted style.
  */
 public static function convert(Style $style)
 {
     $options = array();
     if ($style->isBold()) {
         $options[] = 'bold';
     }
     if ($style->isBlinking()) {
         $options[] = 'blink';
     }
     if ($style->isUnderlined()) {
         $options[] = 'underscore';
     }
     if ($style->isInverse()) {
         $options[] = 'reverse';
     }
     if ($style->isHidden()) {
         $options[] = 'conceal';
     }
     return new OutputFormatterStyle($style->getForegroundColor(), $style->getBackgroundColor(), $options);
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->replace(array(Style::tag('b')->bold(), Style::tag('u')->underlined(), Style::tag('bu')->bold()->underlined(), Style::tag('c1')->fgCyan(), Style::tag('c2')->fgYellow(), Style::tag('error')->fgWhite()->bgRed(), Style::tag('warn')->fgBlack()->bgYellow(), Style::tag('info')->fgCyan(), Style::tag('comment')->fgCyan(), Style::tag('question')->fgBlack()->bgCyan()));
 }
Esempio n. 7
0
 public function testRemoveFormat()
 {
     $formatter = new AnsiFormatter(new StyleSet(array(Style::tag('bold')->bold(), Style::tag('yellow')->fgYellow())));
     $this->assertSame('<no-style>text</no-style>', $formatter->removeFormat('<no-style>text</no-style>'));
 }
Esempio n. 8
0
 public function testIsEmpty()
 {
     $styleSet = new StyleSet();
     $this->assertTrue($styleSet->isEmpty());
     $styleSet->add(Style::tag('style'));
     $this->assertFalse($styleSet->isEmpty());
 }
Esempio n. 9
0
 public function testNotHidden()
 {
     $style = Style::noTag()->hidden()->notHidden();
     $this->assertFalse($style->isHidden());
 }
 public function testUseConfiguredStyleSet()
 {
     $styleSet = new StyleSet();
     $styleSet->add(Style::tag('custom'));
     $this->config->setStyleSet($styleSet)->beginCommand('command')->setHandler(new CallbackHandler(function (Args $args, IO $io) {
         PHPUnit_Framework_Assert::assertSame('text', $io->removeFormat('<custom>text</custom>'));
         return 123;
     }))->end();
     $application = new ConsoleApplication($this->config);
     $args = new StringArgs('command');
     $inputStream = new StringInputStream();
     $outputStream = new BufferedOutputStream();
     $errorStream = new BufferedOutputStream();
     $status = $application->run($args, $inputStream, $outputStream, $errorStream);
     $this->assertSame(123, $status);
 }
Esempio n. 11
0
 public function testRemoveStyle()
 {
     $style1 = Style::tag('custom1');
     $style2 = Style::tag('custom2');
     $this->config->addStyles(array($style1, $style2));
     $this->config->removeStyle('custom1');
     $styleSet = new DefaultStyleSet();
     $styleSet->add($style2);
     $this->assertEquals($styleSet, $this->config->getStyleSet());
 }
Esempio n. 12
0
 public function testRemoveFormat()
 {
     $formatter = new PlainFormatter(new StyleSet(array(Style::tag('bold')->bold())));
     $this->assertSame('<no-style>text</no-style>', $formatter->removeFormat('<bold><no-style>text</no-style></bold>'));
 }
Esempio n. 13
0
 public function getTestCases()
 {
     return array(array(Style::tag('tag'), new OutputFormatterStyle()), array(Style::noTag(), new OutputFormatterStyle()), array(Style::noTag()->fgBlack(), new OutputFormatterStyle('black')), array(Style::noTag()->fgBlue(), new OutputFormatterStyle('blue')), array(Style::noTag()->fgCyan(), new OutputFormatterStyle('cyan')), array(Style::noTag()->fgGreen(), new OutputFormatterStyle('green')), array(Style::noTag()->fgMagenta(), new OutputFormatterStyle('magenta')), array(Style::noTag()->fgRed(), new OutputFormatterStyle('red')), array(Style::noTag()->fgWhite(), new OutputFormatterStyle('white')), array(Style::noTag()->fgYellow(), new OutputFormatterStyle('yellow')), array(Style::noTag()->bgBlack(), new OutputFormatterStyle(null, 'black')), array(Style::noTag()->bgBlue(), new OutputFormatterStyle(null, 'blue')), array(Style::noTag()->bgCyan(), new OutputFormatterStyle(null, 'cyan')), array(Style::noTag()->bgGreen(), new OutputFormatterStyle(null, 'green')), array(Style::noTag()->bgMagenta(), new OutputFormatterStyle(null, 'magenta')), array(Style::noTag()->bgRed(), new OutputFormatterStyle(null, 'red')), array(Style::noTag()->bgWhite(), new OutputFormatterStyle(null, 'white')), array(Style::noTag()->bgYellow(), new OutputFormatterStyle(null, 'yellow')), array(Style::noTag()->bold(), new OutputFormatterStyle(null, null, array('bold'))), array(Style::noTag()->underlined(), new OutputFormatterStyle(null, null, array('underscore'))), array(Style::noTag()->inverse(), new OutputFormatterStyle(null, null, array('reverse'))), array(Style::noTag()->blinking(), new OutputFormatterStyle(null, null, array('blink'))), array(Style::noTag()->hidden(), new OutputFormatterStyle(null, null, array('conceal'))), array(Style::noTag()->fgWhite()->bgBlack()->bold()->hidden(), new OutputFormatterStyle('white', 'black', array('bold', 'conceal'))));
 }