Passed
Push — attributes ( 57ed6a...578d64 )
by Peter
08:20
created
src/Debug/Exceptions/Handlers/Whoops/ExceptionRenderer.php 1 patch
Indentation   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -165,8 +165,4 @@
 block discarded – undo
165 165
             $values = (array)$values;
166 166
 
167 167
             foreach ($values as $value) {
168
-                header("$name:$value", false);
169
-            }
170
-        }
171
-    }
172
-}
168
+                header("$name:$value
173 169
\ No newline at end of file
Please login to merge, or discard this patch.
tests/Console/Commands/Security/SecretGeneratorTest.php 1 patch
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,6 +105,4 @@
 block discarded – undo
105 105
         $this->sut->execute($responseMock);
106 106
         $content2 = file_get_contents($this->configUrl);
107 107
 
108
-        $this->assertNotSame($content1, $content2);
109
-    }
110
-}
108
+        $this->assertNotSame($content1, $content2
111 109
\ No newline at end of file
Please login to merge, or discard this patch.
tests/Authorization/CombinedAdapterTest.php 1 patch
Indentation   -205 removed lines patch added patch discarded remove patch
@@ -12,208 +12,3 @@
 block discarded – undo
12 12
 class CombinedAdapterTest extends TestCase
13 13
 {
14 14
     protected const EXAMPLE_CONFIG = <<<'EOF'
15
-        [policy_definition]
16
-        p = sub, obj, act
17
-
18
-        [role_definition]
19
-        g = _, _
20
-        EOF;
21
-
22
-    /** @var CombinedAdapter - System Under Test */
23
-    protected CombinedAdapter $sut;
24
-
25
-    /** @var CasbinAdapter|MockObject */
26
-    protected $defaultAdapterMock;
27
-
28
-    /** @var CacheManager|MockObject */
29
-    protected $cacheManagerMock;
30
-
31
-    public function setUp(): void
32
-    {
33
-        $this->defaultAdapterMock = $this->createMock(CasbinAdapter::class);
34
-
35
-        $this->cacheManagerMock = $this->createMock(CacheManager::class);
36
-
37
-        $this->sut = new CombinedAdapter($this->defaultAdapterMock, $this->cacheManagerMock);
38
-
39
-        parent::setUp();
40
-    }
41
-
42
-    public function createSutWithoutCacheManager(): void
43
-    {
44
-        $this->cacheManagerMock = null;
45
-
46
-        $this->sut = new CombinedAdapter($this->defaultAdapterMock);
47
-    }
48
-
49
-    /**
50
-     * @return array
51
-     */
52
-    public function loadPolicyWithoutCacheManagerProvider(): array
53
-    {
54
-        $adapterMock0 = $this->createMock(CasbinAdapter::class);
55
-        $adapterMock1 = $this->createMock(CasbinAdapter::class);
56
-        $adapterMock2 = $this->createMock(CasbinAdapter::class);
57
-
58
-        return [
59
-            'no-adapters'  => [[]],
60
-            'one-adapter'  => [[$adapterMock0]],
61
-            'two-adapters' => [[$adapterMock1, $adapterMock2]],
62
-        ];
63
-    }
64
-
65
-    /**
66
-     * @dataProvider loadPolicyWithoutCacheManagerProvider
67
-     *
68
-     * @param array $adaptersMocks
69
-     */
70
-    public function testLoadPolicyCallsAdaptersByDefault(array $adaptersMocks): void
71
-    {
72
-        $this->createSutWithoutCacheManager();
73
-
74
-        $model = new CasbinModel();
75
-
76
-        $this->defaultAdapterMock->expects($this->once())->method('loadPolicy')->with($model);
77
-
78
-        foreach ($adaptersMocks as $adapter) {
79
-            $adapter->expects($this->once())->method('loadPolicy')->with($model);
80
-            $this->sut->registerAdapter($adapter);
81
-        }
82
-
83
-        $this->sut->loadPolicy($model);
84
-    }
85
-
86
-    public function testLoadPolicyCanLoadPoliciesFromCache(): void
87
-    {
88
-        $cacheData = ['g' => [], 'p' => []];
89
-
90
-        $model = new CasbinModel();
91
-
92
-        $this->cacheManagerMock->expects($this->once())->method('getAll')->willReturn($cacheData);
93
-
94
-        $this->defaultAdapterMock->expects($this->never())->method('loadPolicy');
95
-
96
-        $this->sut->loadPolicy($model);
97
-    }
98
-
99
-    public function testLoadPolicyCanPopulatePoliciesFromCache(): void
100
-    {
101
-        $cachedData = [
102
-            'g' => [
103
-                ['joe', 'admin', '', '', ','],
104
-                ['jane', 'user', '', '', ','],
105
-            ],
106
-            'p' => [
107
-                ['user', 'admin_resource_users', 'read', '', ','],
108
-                ['admin', 'admin_resource_users', 'write', '', ','],
109
-            ],
110
-        ];
111
-
112
-        $model = new CasbinModel();
113
-        $model->loadModelFromText(static::EXAMPLE_CONFIG);
114
-
115
-        $this->cacheManagerMock->expects($this->once())->method('getAll')->willReturn($cachedData);
116
-
117
-        $this->defaultAdapterMock->expects($this->never())->method('loadPolicy');
118
-
119
-        $this->sut->loadPolicy($model);
120
-    }
121
-
122
-    public function testLoadPolicyCanStorePoliciesInCache(): void
123
-    {
124
-        $cachedData = [
125
-            'g' => [
126
-                ['joe', 'admin', '', '', ','],
127
-                ['jane', 'user', '', '', ','],
128
-            ],
129
-            'p' => [
130
-                ['user', 'admin_resource_users', 'read', '', ','],
131
-                ['admin', 'admin_resource_users', 'write', '', ','],
132
-            ],
133
-        ];
134
-
135
-        $model = new CasbinModel();
136
-        $model->loadModelFromText(static::EXAMPLE_CONFIG);
137
-
138
-        $model->addPolicies('g', 'g', $cachedData['g']);
139
-        $model->addPolicies('p', 'p', $cachedData['p']);
140
-
141
-        $this->cacheManagerMock->expects($this->once())->method('getAll')->willReturn([]);
142
-
143
-        $this->defaultAdapterMock->expects($this->once())->method('loadPolicy')->with($model);
144
-
145
-        $this->cacheManagerMock->expects($this->once())->method('storeAll')->willReturn(true);
146
-
147
-        $this->sut->loadPolicy($model);
148
-    }
149
-
150
-    public function testSavePolicyCallsDefaultAdapter(): void
151
-    {
152
-        $model = new CasbinModel();
153
-
154
-        $this->defaultAdapterMock
155
-            ->expects($this->once())
156
-            ->method('savePolicy')
157
-            ->with($model);
158
-
159
-        $this->sut->savePolicy($model);
160
-    }
161
-
162
-    public function testAddPolicyCallsDefaultAdapter(): void
163
-    {
164
-        $sec   = 'foo';
165
-        $ptype = 'bar';
166
-        $rule  = 'baz';
167
-
168
-        $this->defaultAdapterMock
169
-            ->expects($this->once())
170
-            ->method('addPolicy')
171
-            ->with($sec, $ptype, [$rule]);
172
-
173
-        $this->sut->addPolicy($sec, $ptype, [$rule]);
174
-    }
175
-
176
-    public function testRemovePolicyCallsDefaultAdapter(): void
177
-    {
178
-        $sec   = 'foo';
179
-        $ptype = 'bar';
180
-        $rule  = 'baz';
181
-
182
-        $this->defaultAdapterMock
183
-            ->expects($this->once())
184
-            ->method('removePolicy')
185
-            ->with($sec, $ptype, [$rule]);
186
-
187
-        $this->sut->removePolicy($sec, $ptype, [$rule]);
188
-    }
189
-
190
-    public function testRemoveFilteredPolicyWithoutFieldValuesCallsDefaultAdapter(): void
191
-    {
192
-        $sec        = 'foo';
193
-        $ptype      = 'bar';
194
-        $fieldIndex = 0;
195
-
196
-        $this->defaultAdapterMock
197
-            ->expects($this->once())
198
-            ->method('removeFilteredPolicy')
199
-            ->with($sec, $ptype, $fieldIndex);
200
-
201
-        $this->sut->removeFilteredPolicy($sec, $ptype, $fieldIndex);
202
-    }
203
-
204
-    public function testRemoveFilteredPolicyWithFieldValuesCallsDefaultAdapter(): void
205
-    {
206
-        $sec         = 'foo';
207
-        $ptype       = 'bar';
208
-        $fieldIndex  = 0;
209
-        $fieldValue0 = 'quix';
210
-        $fieldValue1 = 'tata';
211
-
212
-        $this->defaultAdapterMock
213
-            ->expects($this->once())
214
-            ->method('removeFilteredPolicy')
215
-            ->with($sec, $ptype, $fieldIndex, $fieldValue0, $fieldValue1);
216
-
217
-        $this->sut->removeFilteredPolicy($sec, $ptype, $fieldIndex, $fieldValue0, $fieldValue1);
218
-    }
219
-}
Please login to merge, or discard this patch.
src/Grid/Component/Filters.php 1 patch
Indentation   -159 removed lines patch added patch discarded remove patch
@@ -39,162 +39,3 @@
 block discarded – undo
39 39
      * %2$s - nodes (filters)
40 40
      */
41 41
     protected const DEFAULT_TEMPLATE = <<<'EOT'
42
-        <div class="hidable">
43
-            <p class="hider">%1$s</p>
44
-            <div class="hidee">%2$s</div>
45
-        </div>
46
-        EOT;
47
-
48
-    protected string $template = self::DEFAULT_TEMPLATE;
49
-
50
-    /** @var IFilter[] */
51
-    protected array $nodes = [];
52
-
53
-    protected string $nodeClass = IFilter::class;
54
-
55
-    protected Action $hiderBtn;
56
-
57
-    protected Action $filterBtn;
58
-
59
-    protected Action $resetBtn;
60
-
61
-    /**
62
-     * Filters constructor.
63
-     *
64
-     * @param string[]        $intents
65
-     * @param Attributes|null $attributes
66
-     * @param string|null     $tag
67
-     */
68
-    public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null)
69
-    {
70
-        parent::__construct(null, $intents, $attributes, $tag);
71
-
72
-        $this->hiderBtn  = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]);
73
-        $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], static::ATTRIBUTES_SEARCH);
74
-        $this->resetBtn  = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], static::ATTRIBUTES_RESET);
75
-    }
76
-
77
-    /**
78
-     * @param array $params
79
-     *
80
-     * @return $this
81
-     */
82
-    public function setParams(array $params): Filters
83
-    {
84
-        foreach ($this->nodes as $filter) {
85
-            $filter->setParams($params);
86
-        }
87
-
88
-        return $this;
89
-    }
90
-
91
-    /**
92
-     * @param string $baseUrl
93
-     *
94
-     * @return string
95
-     */
96
-    public function getUrl(string $baseUrl): string
97
-    {
98
-        $queryParts = [];
99
-        foreach ($this->nodes as $filter) {
100
-            $queryPart = $filter->getQueryPart();
101
-            if (!$queryPart) {
102
-                continue;
103
-            }
104
-
105
-            $queryParts[] = $queryPart;
106
-        }
107
-
108
-        if (empty($queryParts)) {
109
-            return $baseUrl;
110
-        }
111
-
112
-        return sprintf('%s%s&', $baseUrl, implode('&', $queryParts));
113
-    }
114
-
115
-    /**
116
-     * @return array
117
-     */
118
-    public function getWhereConditions(): array
119
-    {
120
-        $conditions = [];
121
-        foreach ($this->nodes as $filter) {
122
-            $conditions = array_merge($conditions, $filter->getWhereConditions());
123
-        }
124
-
125
-        return $conditions;
126
-    }
127
-
128
-    /**
129
-     * @return array<string,string>
130
-     */
131
-    public function getSqlParams(): array
132
-    {
133
-        $params = [];
134
-        foreach ($this->nodes as $filter) {
135
-            $params = array_merge($params, $filter->getQueryParams());
136
-        }
137
-
138
-        return $params;
139
-    }
140
-
141
-    /**
142
-     * @return INode[]
143
-     */
144
-    public function getExtendedNodes(): array
145
-    {
146
-        return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes());
147
-    }
148
-
149
-    /**
150
-     * @param string $template
151
-     *
152
-     * @return INode
153
-     */
154
-    public function setTemplate(string $template): INode
155
-    {
156
-        $this->template = $template;
157
-
158
-        return $this;
159
-    }
160
-
161
-    /**
162
-     * @return string
163
-     */
164
-    public function __toString(): string
165
-    {
166
-        $nodes = Collection::__toString();
167
-
168
-        $form = sprintf(self::WITH_CONTENT_TAG, $this->tag, $nodes, new Attributes( [Html5::ATTR_CLASS => 'filter-form']));
169
-
170
-        return sprintf(
171
-            $this->template,
172
-            (string)$this->hiderBtn,
173
-            $form
174
-        );
175
-    }
176
-
177
-    /**
178
-     * @return Action
179
-     */
180
-    public function getHiderBtn(): Action
181
-    {
182
-        return $this->hiderBtn;
183
-    }
184
-
185
-    /**
186
-     * @return Action
187
-     */
188
-    public function getFilterBtn(): Action
189
-    {
190
-        return $this->filterBtn;
191
-    }
192
-
193
-    /**
194
-     * @return Action
195
-     */
196
-    public function getResetBtn(): Action
197
-    {
198
-        return $this->resetBtn;
199
-    }
200
-}
Please login to merge, or discard this patch.