|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Config; |
|
4
|
|
|
|
|
5
|
|
|
use N98\Magento\Command\TestCase; |
|
6
|
|
|
|
|
7
|
|
|
class DeleteCommandTest extends TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @test |
|
11
|
|
|
*/ |
|
12
|
|
|
public function deleteOne() |
|
13
|
|
|
{ |
|
14
|
|
|
$input = array( |
|
15
|
|
|
'command' => 'config:set', |
|
16
|
|
|
'path' => 'n98_magerun/foo/bar', |
|
17
|
|
|
'value' => '1234', |
|
18
|
|
|
); |
|
19
|
|
|
$this->assertDisplayContains($input, 'n98_magerun/foo/bar => 1234'); |
|
20
|
|
|
|
|
21
|
|
|
$input = array( |
|
22
|
|
|
'command' => 'config:delete', |
|
23
|
|
|
'path' => 'n98_magerun/foo/bar', |
|
24
|
|
|
); |
|
25
|
|
|
$this->assertDisplayContains($input, '| n98_magerun/foo/bar | default | 0 |'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @test |
|
30
|
|
|
*/ |
|
31
|
|
|
public function deleteAll() |
|
32
|
|
|
{ |
|
33
|
|
|
$input = array( |
|
34
|
|
|
'command' => 'config:set', |
|
35
|
|
|
'path' => 'n98_magerun/foo/bar', |
|
36
|
|
|
'--scope' => 'stores', |
|
37
|
|
|
'--scope-id' => null, # placeholder |
|
38
|
|
|
'value' => 'fake-value', |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
foreach ($this->getStores() as $store) { |
|
42
|
|
|
$input['--scope-id'] = $store->getId(); |
|
43
|
|
|
$this->assertDisplayContains($input, "n98_magerun/foo/bar => fake-value"); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$input = array( |
|
47
|
|
|
'command' => 'config:delete', |
|
48
|
|
|
'path' => 'n98_magerun/foo/bar', |
|
49
|
|
|
'--all' => true, |
|
50
|
|
|
); |
|
51
|
|
|
$this->assertDisplayContains($input, '| n98_magerun/foo/bar | stores |'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return array|\Magento\Store\Api\Data\StoreInterface[] |
|
56
|
|
|
*/ |
|
57
|
|
|
private function getStores() |
|
58
|
|
|
{ |
|
59
|
|
|
$application = $this->getApplication(); |
|
60
|
|
|
|
|
61
|
|
|
/* @var $storeManager \Magento\Store\Model\StoreManager */ |
|
62
|
|
|
$storeManager = $application->getObjectManager()->get('Magento\Store\Model\StoreManager'); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
return $storeManager->getStores(); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: