$check = ord($actual[$i]) == ord($expected[$i]) ? true : false; if ($check) { break; } } expect($check)->toBe(true); }; }); it("leaves string unchanged whith no options", function () { expect(Cli::color("String"))->toBe("String"); }); it("applies a color using a string as options", function () { $this->check(Cli::color("String", "yellow"), "[0;33;49mSrting[0m"); }); it("applies a complex color using a semicolon separated string as options", function () { $this->check(Cli::color("String", "n;yellow;100"), "[0;33;110mSrting[0m"); $this->check(Cli::color("String", "4;red;100"), "[0;31;110mSrting[0m"); $this->check(Cli::color("String", "n;100;100"), "[0;100;100mSrting[0m"); }); it("applies the 39 default color with unknown color name", function () { $this->check(Cli::color("String", "some_strange_color"), "[0;39;49mSrting[0m"); }); }); describe('->bell()', function () { it("bells", function () { expect(function () { Cli::bell(2); })->toEcho(str_repeat("", 2)); }); }); });
/** * Format a string to output. * * @param string $string The string to format. * @param string|array $options The possible values for an array are: * - `'style`: a style code. * - `'color'`: a color code. * - `'background'`: a background color code. * * The string must respect one of the following format: * - `'style;color;background'` * - `'style;color'` * - `'color'` * */ public function format($string, $options = null) { return $this->_colors ? Cli::color($string, $options) : $string; }