Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CachePoolClearCommand example
$tester
->
execute
(
[
'pools' =>
[
'cache.public_pool'
]
]
)
;
$this
->
assertSame
(
1,
$tester
->
getStatusCode
(
)
, 'cache:pool:clear exits with 1 in case of error'
)
;
$this
->
assertStringNotContainsString
(
'[OK] Cache was successfully cleared.',
$tester
->
getDisplay
(
)
)
;
$this
->
assertStringContainsString
(
'[WARNING] Cache pool "cache.public_pool" could not be cleared.',
$tester
->
getDisplay
(
)
)
;
}
private
function
createCommandTester
(
array
$poolNames
= null
)
{
$application
=
new
Application
(
static
::
$kernel
)
;
$application
->
add
(
new
CachePoolClearCommand
(
static
::
getContainer
(
)
->
get
(
'cache.global_clearer'
)
,
$poolNames
)
)
;
return
new
CommandTester
(
$application
->
find
(
'cache:pool:clear'
)
)
;
}
}
protected
function
setUp
(
)
: void
{
$this
->cachePool =
$this
->
createMock
(
CacheItemPoolInterface::
class
)
;
}
/** * @dataProvider provideCompletionSuggestions */
public
function
testComplete
(
array
$input
, array
$expectedSuggestions
)
{
$application
=
new
Application
(
$this
->
getKernel
(
)
)
;
$application
->
add
(
new
CachePoolClearCommand
(
new
Psr6CacheClearer
(
[
'foo' =>
$this
->cachePool
]
)
,
[
'foo'
]
)
)
;
$tester
=
new
CommandCompletionTester
(
$application
->
get
(
'cache:pool:clear'
)
)
;
$suggestions
=
$tester
->
complete
(
$input
)
;
$this
->
assertSame
(
$expectedSuggestions
,
$suggestions
)
;
}
public
static
function
provideCompletionSuggestions
(
)
{
yield
'pool_name' =>
[
[
'f'
]
,
[