Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
f46cffb4
Commit
f46cffb4
authored
Jun 25, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement console color ansi2html
issue #746
parent
0d03f720
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
152 additions
and
101 deletions
+152
-101
BaseConsole.php
framework/helpers/BaseConsole.php
+102
-101
ConsoleTest.php
tests/unit/framework/helpers/ConsoleTest.php
+50
-0
No files found.
framework/helpers/BaseConsole.php
View file @
f46cffb4
This diff is collapsed.
Click to expand it.
tests/unit/framework/helpers/ConsoleTest.php
View file @
f46cffb4
...
@@ -79,4 +79,54 @@ class ConsoleTest extends TestCase
...
@@ -79,4 +79,54 @@ class ConsoleTest extends TestCase
sleep(1);
sleep(1);
}
}
}*/
}*/
public
function
ansiFormats
()
{
return
[
[
'test'
,
'test'
],
[
Console
::
ansiFormat
(
'test'
,
[
Console
::
FG_RED
]),
'<span style="color: red;">test</span>'
],
[
'abc'
.
Console
::
ansiFormat
(
'def'
,
[
Console
::
FG_RED
])
.
'ghj'
,
'abc<span style="color: red;">def</span>ghj'
],
[
'abc'
.
Console
::
ansiFormat
(
'def'
,
[
Console
::
FG_RED
,
Console
::
BG_GREEN
])
.
'ghj'
,
'abc<span style="color: red;background-color: lime;">def</span>ghj'
],
[
'abc'
.
Console
::
ansiFormat
(
'def'
,
[
Console
::
FG_GREEN
,
Console
::
FG_RED
,
Console
::
BG_GREEN
])
.
'ghj'
,
'abc<span style="color: red;background-color: lime;">def</span>ghj'
],
[
'abc'
.
Console
::
ansiFormat
(
'def'
,
[
Console
::
BOLD
,
Console
::
BG_GREEN
])
.
'ghj'
,
'abc<span style="font-weight: bold;background-color: lime;">def</span>ghj'
],
[
Console
::
ansiFormat
(
'test'
,
[
Console
::
UNDERLINE
,
Console
::
OVERLINED
,
Console
::
CROSSED_OUT
,
Console
::
FG_GREEN
]),
'<span style="text-decoration: underline overline line-through;color: lime;">test</span>'
],
[
Console
::
ansiFormatCode
([
Console
::
RESET
])
.
Console
::
ansiFormatCode
([
Console
::
RESET
]),
''
],
[
Console
::
ansiFormatCode
([
Console
::
RESET
])
.
Console
::
ansiFormatCode
([
Console
::
RESET
])
.
'test'
,
'test'
],
[
Console
::
ansiFormatCode
([
Console
::
RESET
])
.
'test'
.
Console
::
ansiFormatCode
([
Console
::
RESET
]),
'test'
],
[
Console
::
ansiFormatCode
([
Console
::
BOLD
])
.
'abc'
.
Console
::
ansiFormatCode
([
Console
::
RESET
,
Console
::
FG_GREEN
])
.
'ghj'
.
Console
::
ansiFormatCode
([
Console
::
RESET
]),
'<span style="font-weight: bold;">abc</span><span style="color: lime;">ghj</span>'
],
[
Console
::
ansiFormatCode
([
Console
::
FG_GREEN
])
.
' a '
.
Console
::
ansiFormatCode
([
Console
::
BOLD
])
.
'abc'
.
Console
::
ansiFormatCode
([
Console
::
RESET
])
.
'ghj'
,
'<span style="color: lime;"> a <span style="font-weight: bold;">abc</span></span>ghj'
],
[
Console
::
ansiFormat
(
'test'
,
[
Console
::
FG_GREEN
,
Console
::
BG_BLUE
,
Console
::
NEGATIVE
]),
'<span style="background-color: lime;color: blue;">test</span>'
],
[
Console
::
ansiFormat
(
'test'
,
[
Console
::
NEGATIVE
]),
'test'
],
[
Console
::
ansiFormat
(
'test'
,
[
Console
::
CONCEALED
]),
'<span style="visibility: hidden;">test</span>'
],
];
}
/**
* @dataProvider ansiFormats
*/
public
function
testAnsi2Html
(
$ansi
,
$html
)
{
$this
->
assertEquals
(
$html
,
Console
::
ansiToHtml
(
$ansi
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment