Skip to content

Commit ed81577

Browse files
authored
Merge pull request #26 from tattali/fix-tests
Update main.yml
2 parents 0e63c7f + 5225a11 commit ed81577

File tree

8 files changed

+81
-102
lines changed

8 files changed

+81
-102
lines changed

.github/workflows/main.yml

+3-20
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,14 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
php:
27-
- 8.0
28-
- 8.1
27+
- 8.2
2928
dependencies:
3029
- highest
3130
stability:
3231
- stable
3332
symfony-require:
34-
# Test latest LTS
35-
- 5.4.*
36-
# Test last supported version
37-
- 6.0.*
38-
- 6.*
39-
include:
40-
# Tests the lowest set of dependencies
41-
# - symfony-require: 5.4.*
42-
# dependencies: lowest
43-
# stability: stable
44-
# php: 8.0
45-
46-
# Bleeding edge
47-
- symfony-require: 6.*
48-
php: 8.1
49-
dependencies: highest
50-
stability: dev
51-
33+
# Test latest stable version
34+
- 7.*
5235
steps:
5336
- name: Checkout code
5437
uses: actions/checkout@v3

.php-cs-fixer.dist.php

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
'array_syntax' => [
2525
'syntax' => 'short',
2626
],
27-
'braces' => [
28-
'allow_single_line_closure' => true,
29-
],
30-
'compact_nullable_typehint' => true,
3127
'doctrine_annotation_array_assignment' => [
3228
'operator' => '=',
3329
],

composer.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@
3434
}
3535
],
3636
"require": {
37-
"php": ">=7.2.5",
37+
"php": ">=8.2",
3838
"mobiledetect/mobiledetectlib": "^2.8.15",
39-
"symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0",
40-
"symfony/event-dispatcher": "^5.0 || ^6.0 || ^7.0",
41-
"symfony/framework-bundle": "^5.0 || ^6.0 || ^7.0",
42-
"symfony/yaml": "^5.0 || ^6.0 || ^7.0",
39+
"symfony/dependency-injection": "^7.0",
40+
"symfony/event-dispatcher": "^7.0",
41+
"symfony/framework-bundle": "^7.0",
42+
"symfony/yaml": "^7.0",
4343
"twig/twig": "^2.0 || ^3.0"
4444
},
4545
"require-dev": {
46-
"friendsofphp/php-cs-fixer": "^3.4 || ^3.8",
46+
"friendsofphp/php-cs-fixer": "^3.8",
4747
"phpstan/extension-installer": "^1.0",
4848
"phpstan/phpstan-nette": "^1.0",
4949
"phpstan/phpstan-phpunit": "^1.0",
5050
"phpstan/phpstan": "^1.0",
51-
"phpunit/phpunit": "^8.5 || ^9.5",
51+
"phpunit/phpunit": "^9.5",
5252
"squizlabs/php_codesniffer": "^3.6",
53-
"symfony/dotenv": "^5.0 || ^6.0 || ^7.0",
54-
"symfony/phpunit-bridge": "^5.0 || ^6.0 || ^7.0"
53+
"symfony/dotenv": "^7.0",
54+
"symfony/phpunit-bridge": "^7.0"
5555
},
5656
"config": {
5757
"sort-packages": true,

src/EventListener/RequestResponseListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ protected function getRedirectResponse(Request $request, string $view): ?Redirec
272272
*/
273273
protected function prepareResponseModification(string $view): void
274274
{
275-
$this->modifyResponseClosure = function (DeviceView $deviceView, ResponseEvent $event) use ($view) {
275+
$this->modifyResponseClosure = static function (DeviceView $deviceView, ResponseEvent $event) use ($view) {
276276
return $deviceView->modifyResponse($view, $event->getResponse());
277277
};
278278
}

tests/DataCollector/DeviceDataCollectorTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use MobileDetectBundle\Helper\DeviceView;
1919
use PHPUnit\Framework\MockObject\MockObject;
2020
use PHPUnit\Framework\TestCase;
21-
use Symfony\Component\HttpFoundation\ParameterBag;
21+
use Symfony\Component\HttpFoundation\InputBag;
2222
use Symfony\Component\HttpFoundation\Request;
2323
use Symfony\Component\HttpFoundation\RequestStack;
2424
use Symfony\Component\HttpFoundation\Response;
@@ -53,8 +53,8 @@ protected function setUp(): void
5353
parent::setUp();
5454

5555
$this->request = $this->getMockBuilder(Request::class)->getMock();
56-
$this->request->query = new ParameterBag();
57-
$this->request->cookies = new ParameterBag();
56+
$this->request->query = new InputBag();
57+
$this->request->cookies = new InputBag();
5858
$this->request->server = new ServerBag();
5959
$this->request->expects(self::any())->method('duplicate')->willReturn($this->request);
6060

@@ -75,7 +75,7 @@ public function testCollectCurrentViewMobileIsCurrent(): void
7575
'status_code' => Response::HTTP_FOUND,
7676
'action' => RequestResponseListener::REDIRECT,
7777
];
78-
$this->request->cookies = new ParameterBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_MOBILE]);
78+
$this->request->cookies = new InputBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_MOBILE]);
7979
$deviceView = new DeviceView($this->requestStack);
8080
$deviceDataCollector = new DeviceDataCollector($deviceView);
8181
$deviceDataCollector->setRedirectConfig($redirectConfig);
@@ -109,24 +109,24 @@ public function testCollectCurrentViewMobileCanUseTablet(): void
109109
'status_code' => Response::HTTP_FOUND,
110110
'action' => RequestResponseListener::REDIRECT,
111111
];
112-
$this->request->query = new ParameterBag(['param1' => 'value1']);
112+
$this->request->query = new InputBag(['param1' => 'value1']);
113113
$this->request->expects(self::any())->method('getSchemeAndHttpHost')->willReturn('http://t.testsite.com');
114114
$this->request->expects(self::any())->method('getBaseUrl')->willReturn('/base-url');
115115
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/path-info');
116116
$test = $this;
117-
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(function () use ($test) {
117+
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(static function () use ($test) {
118118
$qs = Request::normalizeQueryString($test->request->server->get('QUERY_STRING'));
119119

120120
return '' === $qs ? null : $qs;
121121
});
122-
$this->request->expects(self::any())->method('getUri')->willReturnCallback(function () use ($test) {
122+
$this->request->expects(self::any())->method('getUri')->willReturnCallback(static function () use ($test) {
123123
if (null !== $qs = $test->request->getQueryString()) {
124124
$qs = '?'.$qs;
125125
}
126126

127127
return $test->request->getSchemeAndHttpHost().$test->request->getBaseUrl().$test->request->getPathInfo().$qs;
128128
});
129-
$this->request->cookies = new ParameterBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_MOBILE]);
129+
$this->request->cookies = new InputBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_MOBILE]);
130130
$deviceView = new DeviceView($this->requestStack);
131131
$deviceDataCollector = new DeviceDataCollector($deviceView);
132132
$deviceDataCollector->setRedirectConfig($redirectConfig);
@@ -172,24 +172,24 @@ public function testCollectCurrentViewFullCanUseMobile(): void
172172
'status_code' => Response::HTTP_FOUND,
173173
'action' => RequestResponseListener::REDIRECT,
174174
];
175-
$this->request->query = new ParameterBag(['param1' => 'value1']);
175+
$this->request->query = new InputBag(['param1' => 'value1']);
176176
$this->request->expects(self::any())->method('getSchemeAndHttpHost')->willReturn('http://t.testsite.com');
177177
$this->request->expects(self::any())->method('getBaseUrl')->willReturn('/base-url');
178178
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/path-info');
179179
$test = $this;
180-
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(function () use ($test) {
180+
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(static function () use ($test) {
181181
$qs = Request::normalizeQueryString($test->request->server->get('QUERY_STRING'));
182182

183183
return '' === $qs ? null : $qs;
184184
});
185-
$this->request->expects(self::any())->method('getUri')->willReturnCallback(function () use ($test) {
185+
$this->request->expects(self::any())->method('getUri')->willReturnCallback(static function () use ($test) {
186186
if (null !== $qs = $test->request->getQueryString()) {
187187
$qs = '?'.$qs;
188188
}
189189

190190
return $test->request->getSchemeAndHttpHost().$test->request->getBaseUrl().$test->request->getPathInfo().$qs;
191191
});
192-
$this->request->cookies = new ParameterBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_FULL]);
192+
$this->request->cookies = new InputBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_FULL]);
193193
$deviceView = new DeviceView($this->requestStack);
194194
$deviceDataCollector = new DeviceDataCollector($deviceView);
195195
$deviceDataCollector->setRedirectConfig($redirectConfig);
@@ -235,24 +235,24 @@ public function testCollectCurrentViewFullCantUseMobile(): void
235235
'status_code' => Response::HTTP_FOUND,
236236
'action' => RequestResponseListener::REDIRECT,
237237
];
238-
$this->request->query = new ParameterBag(['param1' => 'value1']);
238+
$this->request->query = new InputBag(['param1' => 'value1']);
239239
$this->request->expects(self::any())->method('getSchemeAndHttpHost')->willReturn('http://testsite.com');
240240
$this->request->expects(self::any())->method('getBaseUrl')->willReturn('/base-url');
241241
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/path-info');
242242
$test = $this;
243-
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(function () use ($test) {
243+
$this->request->expects(self::any())->method('getQueryString')->willReturnCallback(static function () use ($test) {
244244
$qs = Request::normalizeQueryString($test->request->server->get('QUERY_STRING'));
245245

246246
return '' === $qs ? null : $qs;
247247
});
248-
$this->request->expects(self::any())->method('getUri')->willReturnCallback(function () use ($test) {
248+
$this->request->expects(self::any())->method('getUri')->willReturnCallback(static function () use ($test) {
249249
if (null !== $qs = $test->request->getQueryString()) {
250250
$qs = '?'.$qs;
251251
}
252252

253253
return $test->request->getSchemeAndHttpHost().$test->request->getBaseUrl().$test->request->getPathInfo().$qs;
254254
});
255-
$this->request->cookies = new ParameterBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_FULL]);
255+
$this->request->cookies = new InputBag([DeviceView::COOKIE_KEY_DEFAULT => DeviceView::VIEW_FULL]);
256256
$deviceView = new DeviceView($this->requestStack);
257257
$deviceDataCollector = new DeviceDataCollector($deviceView);
258258
$deviceDataCollector->setRedirectConfig($redirectConfig);

tests/EventListener/RequestResponseListenerTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use PHPUnit\Framework\TestCase;
1313
use Symfony\Component\HttpFoundation\Cookie;
1414
use Symfony\Component\HttpFoundation\HeaderBag;
15-
use Symfony\Component\HttpFoundation\ParameterBag;
15+
use Symfony\Component\HttpFoundation\InputBag;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\RequestStack;
1818
use Symfony\Component\HttpFoundation\Response;
@@ -71,8 +71,8 @@ protected function setUp(): void
7171
$this->request->expects(self::any())->method('getSchemeAndHttpHost')->willReturn('http://testhost.com');
7272
$this->request->expects(self::any())->method('get')->willReturn('value');
7373
$this->request->expects(self::any())->method('getUriForPath')->willReturn('/');
74-
$this->request->query = new ParameterBag();
75-
$this->request->cookies = new ParameterBag();
74+
$this->request->query = new InputBag();
75+
$this->request->cookies = new InputBag();
7676

7777
$this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock();
7878
$this->requestStack->expects(self::any())
@@ -89,7 +89,7 @@ protected function setUp(): void
8989

9090
public function testHandleRequestHasSwitchParam(): void
9191
{
92-
$this->request->query = new ParameterBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
92+
$this->request->query = new InputBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
9393
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/');
9494
$deviceView = new DeviceView($this->requestStack);
9595
$deviceView->setRedirectConfig([DeviceView::VIEW_MOBILE => ['status_code' => Response::HTTP_FOUND]]);
@@ -114,7 +114,7 @@ public function testHandleRequestHasSwitchParam(): void
114114

115115
public function testHandleRequestBis(): void
116116
{
117-
$this->request->query = new ParameterBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
117+
$this->request->query = new InputBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
118118
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/');
119119
$deviceView = new DeviceView($this->requestStack);
120120
$deviceView->setRedirectConfig([DeviceView::VIEW_MOBILE => ['status_code' => Response::HTTP_FOUND]]);
@@ -141,7 +141,7 @@ public function testHandleRequestHasSwitchParamAndQuery(): void
141141
{
142142
$this->config['mobile'] = ['is_enabled' => true, 'host' => 'http://mobilehost.com'];
143143

144-
$this->request->query = new ParameterBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
144+
$this->request->query = new InputBag(['myparam' => 'myvalue', $this->switchParam => DeviceView::VIEW_MOBILE]);
145145
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/');
146146
$this->request->expects(self::any())->method('get')->willReturn('value');
147147
$this->router->expects(self::exactly(2))->method('getRouteCollection')->willReturn(
@@ -241,7 +241,7 @@ public function testHandleRequestHasTabletRedirect(): void
241241
{
242242
$this->config['tablet'] = ['is_enabled' => true, 'host' => 'http://t.testsite.com', 'status_code' => Response::HTTP_FOUND];
243243

244-
$this->request->query = new ParameterBag(['some' => 'param']);
244+
$this->request->query = new InputBag(['some' => 'param']);
245245
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/some/parameters');
246246
$this->request->expects(self::any())->method('get')->willReturn('value');
247247
$this->router->expects(self::exactly(2))->method('getRouteCollection')->willReturn(
@@ -284,7 +284,7 @@ public function testHandleRequestWithDifferentSwitchParamRedirect(): void
284284

285285
$switchParam = 'custom_param';
286286

287-
$this->request->query = new ParameterBag(['some' => 'param']);
287+
$this->request->query = new InputBag(['some' => 'param']);
288288
$this->request->expects(self::any())->method('getPathInfo')->willReturn('/some/parameters');
289289
$this->router->expects(self::exactly(2))->method('getRouteCollection')->willReturn(
290290
$this->createRouteCollectionWithRouteAndRoutingOption(RequestResponseListener::REDIRECT, 2)

0 commit comments

Comments
 (0)