Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProgressBar example
/** * @return void */
public
function
newLine
(
int
$count
= 1
)
{
$this
->output->
write
(
str_repeat
(
\PHP_EOL,
$count
)
)
;
}
public
function
createProgressBar
(
int
$max
= 0
)
: ProgressBar
{
return
new
ProgressBar
(
$this
->output,
$max
)
;
}
/** * @return void */
public
function
write
(
string|iterable
$messages
, bool
$newline
= false, int
$type
= self::OUTPUT_NORMAL
)
{
$this
->output->
write
(
$messages
,
$newline
,
$type
)
;
}
/** * @return void */
$this
->colSize =
getenv
(
'COLUMNS'
)
;
putenv
(
'COLUMNS=120'
)
;
}
protected
function
tearDown
(
)
: void
{
putenv
(
$this
->colSize ? 'COLUMNS='.
$this
->colSize : 'COLUMNS'
)
;
}
public
function
testMultipleStart
(
)
{
$bar
=
new
ProgressBar
(
$output
=
$this
->
getOutputStream
(
)
, 0, 0
)
;
$bar
->
start
(
)
;
$bar
->
advance
(
)
;
$bar
->
start
(
)
;
rewind
(
$output
->
getStream
(
)
)
;
$this
->
assertEquals
(
' 0 [>---------------------------]'.
$this
->
generateOutput
(
' 1 [->--------------------------]'
)
.
$this
->
generateOutput
(
' 0 [>---------------------------]'
)
,
stream_get_contents
(
$output
->
getStream
(
)
)
)
;
}
/** * @return void */
public
function
newLine
(
int
$count
= 1
)
{
$this
->output->
write
(
str_repeat
(
\PHP_EOL,
$count
)
)
;
}
public
function
createProgressBar
(
int
$max
= 0
)
: ProgressBar
{
return
new
ProgressBar
(
$this
->output,
$max
)
;
}
/** * @return void */
public
function
write
(
string|iterable
$messages
, bool
$newline
= false, int
$type
= self::OUTPUT_NORMAL
)
{
$this
->output->
write
(
$messages
,
$newline
,
$type
)
;
}
/** * @return void */