How to use colorizer class

Best Atoum code snippet using colorizer

Cli.php

Source: Cli.php Github

copy

Full Screen

1<?php2declare(strict_types=1);3/​**4 * Hoa5 *6 *7 * @license8 *9 * New BSD License10 *11 * Copyright © 2007-2017, Hoa community. All rights reserved.12 *13 * Redistribution and use in source and binary forms, with or without14 * modification, are permitted provided that the following conditions are met:15 * * Redistributions of source code must retain the above copyright16 * notice, this list of conditions and the following disclaimer.17 * * Redistributions in binary form must reproduce the above copyright18 * notice, this list of conditions and the following disclaimer in the19 * documentation and/​or other materials provided with the distribution.20 * * Neither the name of the Hoa nor the names of its contributors may be21 * used to endorse or promote products derived from this software without22 * specific prior written permission.23 *24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE34 * POSSIBILITY OF SUCH DAMAGE.35 */​36namespace Hoa\Test\Report\Cli;37use atoum;38use atoum\report\fields\runner;39use atoum\report\fields\test;40class Cli extends atoum\reports\realtime41{42 private $runnerTestsCoverageField;43 public function __construct()44 {45 parent::__construct();46 $defaultColorizer = new Colorizer('foreground(' . Colors::BLUE . ')');47 $defaultPromptColorizer = clone $defaultColorizer;48 $defaultInfoColorizer = new Colorizer('foreground(' . Colors::YELLOW . ')');49 $firstLevelPrompt = new atoum\cli\prompt('> ', $defaultPromptColorizer);50 $secondLevelPrompt = new atoum\cli\prompt('~> ', $defaultPromptColorizer);51 $thirdLevelPrompt = new atoum\cli\prompt('~~> ', $defaultPromptColorizer);52 $atoumPathField = new runner\atoum\path\cli();53 $atoumPathField54 ->setPrompt($firstLevelPrompt)55 ->setTitleColorizer($defaultColorizer);56 $this->addField($atoumPathField);57 $atoumVersionField = new runner\atoum\version\cli();58 $atoumVersionField59 ->setTitlePrompt($firstLevelPrompt)60 ->setTitleColorizer($defaultColorizer);61 $this->addField($atoumVersionField);62 $phpPathField = new runner\php\path\cli();63 $phpPathField64 ->setPrompt($firstLevelPrompt)65 ->setTitleColorizer($defaultColorizer);66 $this->addField($phpPathField);67 $phpVersionField = new runner\php\version\cli();68 $phpVersionField69 ->setTitlePrompt($firstLevelPrompt)70 ->setTitleColorizer($defaultColorizer)71 ->setVersionPrompt($secondLevelPrompt);72 $this->addField($phpVersionField);73 $runnerTestsDurationField = new runner\tests\duration\cli();74 $runnerTestsDurationField75 ->setPrompt(new atoum\cli\prompt("\n" . '> ', $defaultInfoColorizer))76 ->setTitleColorizer($defaultInfoColorizer);77 $this->addField($runnerTestsDurationField);78 $runnerTestsMemoryField = new runner\tests\memory\cli();79 $runnerTestsMemoryField80 ->setPrompt(new atoum\cli\prompt('> ', $defaultInfoColorizer))81 ->setTitleColorizer($defaultInfoColorizer);82 $this->addField($runnerTestsMemoryField);83 $this->runnerTestsCoverageField = new runner\tests\coverage\cli();84 $this->runnerTestsCoverageField85 ->setTitlePrompt($firstLevelPrompt)86 ->setTitleColorizer($defaultColorizer)87 ->setClassPrompt($secondLevelPrompt)88 ->setMethodPrompt($thirdLevelPrompt);89 $this->addField($this->runnerTestsCoverageField);90 $runnerDurationField = new runner\duration\cli();91 $runnerDurationField92 ->setPrompt(new atoum\cli\prompt('> ', $defaultInfoColorizer))93 ->setTitleColorizer($defaultInfoColorizer);94 $this->addField($runnerDurationField);95 $runnerResultField = new Fields\Result();96 $runnerResultField97 ->setSuccessColorizer(new Colorizer('background(' . Colors::GREEN . ') foreground(' . Colors::WHITE . ')'))98 ->setFailureColorizer(new Colorizer('background(' . Colors::MAGENTA . ') foreground(' . Colors::WHITE . ')'));99 $this->addField($runnerResultField);100 $failureColorizer = new Colorizer('foreground(' . Colors::MAGENTA . ')');101 $failureTitlePrompt = new atoum\cli\prompt("\n");102 $failureTitlePrompt->setColorizer($failureColorizer);103 $failurePrompt = clone $secondLevelPrompt;104 $failurePrompt->setColorizer($failureColorizer);105 $runnerFailuresField = new runner\failures\cli();106 $runnerFailuresField107 ->setTitlePrompt($failureTitlePrompt)108 ->setTitleColorizer($failureColorizer)109 ->setMethodPrompt($failurePrompt);110 $this->addField($runnerFailuresField);111 $runnerOutputsField = new runner\outputs\cli();112 $runnerOutputsField113 ->setTitlePrompt($firstLevelPrompt)114 ->setTitleColorizer($defaultColorizer)115 ->setMethodPrompt($secondLevelPrompt);116 $this->addField($runnerOutputsField);117 $errorColorizer = new Colorizer('foreground(' . Colors::YELLOW . ')');118 $errorTitlePrompt = new atoum\cli\prompt("\n");119 $errorTitlePrompt->setColorizer($errorColorizer);120 $errorMethodPrompt = clone $secondLevelPrompt;121 $errorMethodPrompt->setColorizer($errorColorizer);122 $errorPrompt = clone $thirdLevelPrompt;123 $errorPrompt->setColorizer($errorColorizer);124 $runnerErrorsField = new runner\errors\cli();125 $runnerErrorsField126 ->setTitlePrompt($errorTitlePrompt)127 ->setTitleColorizer($errorColorizer)128 ->setMethodPrompt($errorMethodPrompt)129 ->setErrorPrompt($errorPrompt);130 $this->addField($runnerErrorsField);131 $exceptionColorizer = new Colorizer('foreground(' . Colors::YELLOW . ')');132 $exceptionTitlePrompt = new atoum\cli\prompt("\n");133 $exceptionTitlePrompt->setColorizer($exceptionColorizer);134 $exceptionMethodPrompt = clone $secondLevelPrompt;135 $exceptionMethodPrompt->setColorizer($exceptionColorizer);136 $exceptionPrompt = clone $thirdLevelPrompt;137 $exceptionPrompt->setColorizer($exceptionColorizer);138 $runnerExceptionsField = new runner\exceptions\cli();139 $runnerExceptionsField140 ->setTitlePrompt($exceptionTitlePrompt)141 ->setTitleColorizer($exceptionColorizer)142 ->setMethodPrompt($exceptionMethodPrompt)143 ->setExceptionPrompt($exceptionPrompt);144 $this->addField($runnerExceptionsField);145 $uncompletedTestColorizer = new Colorizer('foreground(' . Colors::GRAY . ')');146 $uncompletedTestTitlePrompt = new atoum\cli\prompt("\n");147 $uncompletedTestTitlePrompt->setColorizer($uncompletedTestColorizer);148 $uncompletedTestMethodPrompt = clone $secondLevelPrompt;149 $uncompletedTestMethodPrompt->setColorizer($uncompletedTestColorizer);150 $uncompletedTestOutputPrompt = clone $thirdLevelPrompt;151 $uncompletedTestOutputPrompt->setColorizer($uncompletedTestColorizer);152 $runnerUncompletedField = new Fields\Uncompleted();153 $runnerUncompletedField154 ->setTitlePrompt($uncompletedTestTitlePrompt)155 ->setTitleColorizer($uncompletedTestColorizer)156 ->setMethodPrompt($uncompletedTestMethodPrompt)157 ->setOutputPrompt($uncompletedTestOutputPrompt);158 $this->addField($runnerUncompletedField);159 $voidTestColorizer = new Colorizer('foreground(' . Colors::YELLOW . ')');160 $voidTestTitlePrompt = new atoum\cli\prompt("\n");161 $voidTestTitlePrompt->setColorizer($voidTestColorizer);162 $voidTestMethodPrompt = clone $secondLevelPrompt;163 $voidTestMethodPrompt->setColorizer($voidTestColorizer);164 $runnerVoidField = new Fields\Nil();165 $runnerVoidField166 ->setTitlePrompt($voidTestTitlePrompt)167 ->setTitleColorizer($voidTestColorizer)168 ->setMethodPrompt($voidTestMethodPrompt);169 $this->addField($runnerVoidField);170 $skippedTestColorizer = new Colorizer('foreground(' . Colors::GRAY . ')');171 $skippedTestMethodPrompt = clone $secondLevelPrompt;172 $skippedTestMethodPrompt->setColorizer($skippedTestColorizer);173 $runnerSkippedField = new runner\tests\skipped\cli();174 $runnerSkippedField175 ->setTitlePrompt($firstLevelPrompt)176 ->setTitleColorizer($skippedTestColorizer)177 ->setMethodPrompt($skippedTestMethodPrompt);178 $this->addField($runnerSkippedField);179 $testRunField = new test\run\cli();180 $testRunField181 ->setPrompt(new atoum\cli\prompt("\n" . 'Suite ', $defaultPromptColorizer))182 ->setColorizer($defaultColorizer);183 $this->addField($testRunField);184 $this->addField(new test\event\cli());185 $testDurationField = new Fields\Duration();186 $testDurationField187 ->setPrompt($secondLevelPrompt);188 $this->addField($testDurationField);189 $testMemoryField = new Fields\Memory();190 $testMemoryField191 ->setPrompt($secondLevelPrompt);192 $this->addField($testMemoryField);193 }194 public function hideClassesCoverageDetails()195 {196 $this->runnerTestsCoverageField->hideClassesCoverageDetails();197 return $this;198 }199 public function hideMethodsCoverageDetails()200 {201 $this->runnerTestsCoverageField->hideMethodsCoverageDetails();202 return $this;203 }204}...

Full Screen

Full Screen

colorizer.admin.inc

Source: colorizer.admin.inc Github

copy

Full Screen

...12 *13 * $show_files determines if fields for template files is shown14 * $show_submit determines is a submit button is added to the form15 */​16function colorizer_admin_form($show_files = TRUE, $show_submit = TRUE) {17 $base = drupal_get_path('module', 'colorizer');18 drupal_add_js($base . '/​js/​colorizer.js');19 $theme = $GLOBALS['theme'];20 $instance = $theme;21 /​/​ allow other modules to change the instance we are updating22 /​/​ allows for group-specific color instances rather than tying to theme23 drupal_alter('colorizer_instance', $instance);24 $css_file = variable_get('colorizer_cssfile', '');25 $inc_file = variable_get('colorizer_incfile', '');26 $preview_file = variable_get('colorizer_previewfile', '');27 if ($show_files) {28 $form['colorizer_global'] = array(29 '#type' => 'fieldset',30 '#title' => t('Global Settings'),31 );32 $form['colorizer_global']['colorizer_cssfile'] = array(33 '#type' => 'textfield',34 '#title' => t('CSS template'),35 '#default_value' => $css_file,36 '#size' => 30,37 '#description' => t('CSS file template (relative to theme path) to control theme colors.'),38 );39 $form['colorizer_global']['colorizer_incfile'] = array(40 '#type' => 'textfield',41 '#title' => t('Color.inc file'),42 '#default_value' => $inc_file,43 '#size' => 30,44 '#description' => t('Path to color.inc file (relative to theme path) defining color templates.'),45 );46 $form['colorizer_global']['colorizer_previewfile'] = array(47 '#type' => 'textfield',48 '#title' => t('Extra preview HTML file'),49 '#default_value' => $preview_file,50 '#size' => 30,51 '#description' => t('Path to extra preview HTML file (relative to theme path).'),52 );53 }54 $file = colorizer_load($instance, 'stylesheet');55 if (!empty($file)) {56 $form['colorizer_reset'] = array(57 '#type' => 'checkbox',58 '#title' => t('Reset colors to default'),59 '#description' => t('Check this option and Save configuration to remove custom colors cached for this theme.')60 );61 }62 $form['colorizer_colors'] = array(63 '#type' => 'fieldset',64 '#title' => t('Color Scheme Settings'),65 );66 $preview_file = drupal_get_path('theme', $theme) . '/​' . $preview_file;67 if (is_file($preview_file)) {68 $preview_data = file_get_contents($preview_file);69 $form['colorizer_colors']['preview'] = array(70 '#markup' => $preview_data,71 '#prefix' => "<div id='colorizer-preview'>",72 '#suffix' => '</​div>',73 '#title' => t('Color Scheme Settings'),74 );75 }76 /​/​ Most of this copied from Color module77 $info = colorizer_get_info($theme, TRUE);78 if (!empty($info['schemes'])) {79 $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());80 $color_sets = array();81 $schemes = array();82 foreach ($info['schemes'] as $key => $scheme) {83 $color_sets[$key] = $scheme['title'];84 $schemes[$key] = $scheme['colors'];85 $schemes[$key] += $info['schemes']['default']['colors'];86 }87 /​/​ See if we're using a predefined scheme.88 /​/​ Note: we use the original theme when the default scheme is chosen.89 $current_scheme = colorizer_load($instance, 'palette');90 foreach ($schemes as $key => $scheme) {91 if ($current_scheme == $scheme) {92 $scheme_name = $key;93 break;94 }95 }96 if (empty($scheme_name)) {97 if (empty($current_scheme)) {98 $scheme_name = 'default';99 }100 else {101 $scheme_name = '';102 }103 }104 $file = drupal_get_path('theme', $theme) . '/​' . $css_file;105 $style = '';106 if (file_exists($file)) {107 /​/​ Aggregate @imports recursively for each configured top level CSS file108 /​/​ without optimization. Aggregation and optimization will be109 /​/​ handled by drupal_build_css_cache() only.110 $style = drupal_load_stylesheet($file, FALSE);111 }112 /​/​ Add scheme selector.113 /​/​ we re-use files from the core color module here114 /​/​ hard code modules/​color path since drupal_get_path only115 /​/​ returns for enabled modules116 $form['colorizer_colors']['scheme'] = array(117 '#type' => 'select',118 '#title' => t('Color scheme'),119 '#options' => $color_sets,120 '#default_value' => $scheme_name,121 '#prefix' => '<div class="colorizer-form clearfix">',122 '#attached' => array(123 /​/​ Add Farbtastic color picker.124 'library' => array(125 array('system', 'farbtastic'),126 ),127 /​/​ Add custom CSS.128 'css' => array(129 $base . '/​css/​colorizer_admin.css' => array(),130 ),131 /​/​ Add custom JavaScript.132 'js' => array(133 $base . '/​js/​colorizer.js',134 array(135 'data' => array(136 'color' => array(137 'reference' => colorizer_get_palette($theme, $instance, TRUE),138 'schemes' => $schemes,139 ),140 'gradients' => $info['gradients'],141 'css' => $style,142 ),143 'type' => 'setting',144 ),145 ),146 ),147 );148 /​/​ Add palette fields.149 $palette = colorizer_get_palette($theme, $instance);150 $names = $info['fields'];151 $form['colorizer_colors']['palette']['#tree'] = TRUE;152 $form['colorizer_colors']['palette']['#prefix'] = '<div id="palette" class="clearfix">';153 $form['colorizer_colors']['palette']['#suffix'] = '</​div></​div>';154 foreach ($palette as $name => $value) {155 if (isset($names[$name])) {156 $form['colorizer_colors']['palette'][$name] = array(157 '#type' => 'textfield',158 '#title' => check_plain($names[$name]),159 '#default_value' => $value,160 '#size' => 8,161 );162 }163 }164 $form['theme'] = array('#type' => 'value', '#value' => $theme);165 $form['instance'] = array('#type' => 'value', '#value' => $instance);166 $form['info'] = array('#type' => 'value', '#value' => $info);167 }168 elseif (!$show_files) {169 $form['colorizer_help'] = array(170 '#markup' => '<p>' . t('Configure the Colorizer module here: ') .171 l('admin/​appearance/​colorizer', 'admin/​appearance/​colorizer') . '</​p>',172 );173 }174 if ($show_submit) {175 $form['actions'] = array(176 '#type' => 'actions',177 );178 if (!$show_files) {179 /​/​ only show regular Save button when not on the global config page180 $form['actions']['submit'] = array(181 '#type' => 'submit',182 '#value' => t('Save configuration'),183 );184 }185 $form['actions']['save_default'] = array(186 '#type' => 'submit',187 '#value' => t('Save as default'),188 );189 $form['actions']['colorizer_clearcache'] = array(190 '#type' => 'submit',191 '#value' => t('Clear Colorizer Cache'),192 );193 }194 return $form;195}196/​**197 * Menu callback for Appearance settings form for Colorizer198 */​199function colorizer_admin_settings() {200 $form = colorizer_admin_form();201 return $form;202}203/​**204 * Helper function to validate a form for colorizer fields205 * Copied from Color module206 */​207function colorizer_admin_form_validate($form, &$form_state) {208 /​/​ Only accept hexadecimal CSS color strings to avoid XSS upon use.209 if (!empty($form_state['values']['palette'])) {210 foreach ($form_state['values']['palette'] as $key => $color) {211 if (!preg_match('/​^#([a-f0-9]{3}){1,2}$/​iD', $color)) {212 form_set_error('palette][' . $key, t('%name must be a valid hexadecimal CSS color value.',213 array('%name' => $form['colorizer_colors']['palette'][$key]['#title'])));214 }215 }216 }217}218/​**219 * Form validation handler for colorizer_admin_settings().220 */​221function colorizer_admin_settings_validate($form, &$form_state) {222 return colorizer_admin_form_validate($form, $form_state);223}224/​**225 * Helper function to submit/​save a colorizer form226 * Mostly copied from Color module227 */​228function colorizer_admin_form_submit($form, &$form_state) {229 global $theme_key;230 /​/​ Save the file locations231 if (!empty($form_state['values']['op']) && ($form_state['values']['op'] == $form_state['values']['colorizer_clearcache'])) {232 /​/​ clear the colorizer css cache233 colorizer_clearcache();234 }235 if (isset($form_state['values']['colorizer_cssfile'])) {236 variable_set('colorizer_cssfile', $form_state['values']['colorizer_cssfile']);237 variable_set('colorizer_incfile', $form_state['values']['colorizer_incfile']);238 variable_set('colorizer_previewfile', $form_state['values']['colorizer_previewfile']);239 }240 $instance = !empty($form_state['values']['instance']) ? $form_state['values']['instance'] : '';241 if (!empty($form_state['values']['op']) && ($form_state['values']['op'] == $form_state['values']['save_default'])) {242 /​/​ save as default instance243 $instance = $theme_key;244 }245 if (!empty($form_state['values']['colorizer_reset'])) {246 colorizer_delete($instance);247 return;248 }249 /​/​ The rest of this is from Color250 /​/​ Get theme coloring info.251 if (!isset($form_state['values']['info'])) {252 return;253 }254 $theme = $form_state['values']['theme'];255 $info = $form_state['values']['info'];256 /​/​ Resolve palette.257 $palette = $form_state['values']['palette'];258 if ($form_state['values']['scheme'] != '') {259 foreach ($palette as $key => $color) {260 if (isset($info['schemes'][$form_state['values']['scheme']]['colors'][$key])) {261 $palette[$key] = $info['schemes'][$form_state['values']['scheme']]['colors'][$key];262 }263 }264 $palette += $info['schemes']['default']['colors'];265 }266 colorizer_save($instance, array('palette' => $palette));267 colorizer_update_stylesheet($theme, $instance, $palette);268}269/​**270 * Form submission handler for colorizer_admin_settings().271 */​272function colorizer_admin_settings_submit($form, &$form_state) {273 return colorizer_admin_form_submit($form, $form_state);274}...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Getting Rid of Technical Debt in Agile Projects

Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.

Complete Tutorial On Appium Parallel Testing [With Examples]

In today’s fast-paced world, the primary goal of every business is to release their application or websites to the end users as early as possible. As a result, businesses constantly search for ways to test, measure, and improve their products. With the increase in competition, faster time to market (TTM) has become vital for any business to survive in today’s market. However, one of the possible challenges many business teams face is the release cycle time, which usually gets extended for several reasons.

Developers and Bugs &#8211; why are they happening again and again?

Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.

Starting &#038; growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Six Agile Team Behaviors to Consider

Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful