Skip to content

Commit ee0aad1

Browse files
hacfidbu
authored andcommitted
Don't use the deprecated interface with Symfony 4.2 (#208)
* Update PHPUnit version (namespaced classes), remove hhvm from Travis build matrix * Don't use the deprecated interface with Symfony 4.2
1 parent 1f5ee7f commit ee0aad1

30 files changed

+115
-92
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cache:
1212
directories:
1313
- $HOME/.composer/cache/files
1414

15-
env: SYMFONY_VERSION='3.3.*' SYMFONY_PHPUNIT_VERSION=5.5
15+
env: SYMFONY_VERSION='3.3.*'
1616

1717
matrix:
1818
include:
@@ -21,7 +21,6 @@ matrix:
2121
- COMPOSER_FLAGS="--prefer-lowest"
2222
- SYMFONY_VERSION='2.8.*'
2323
- php: 7.1
24-
env:
2524
env:
2625
- SYMFONY_VERSION='2.8.*'
2726
- php: 7.1
@@ -38,9 +37,10 @@ matrix:
3837
- SYMFONY_VERSION='3.4.*@BETA'
3938
- php: 7.1
4039
env:
41-
- SYMFONY_VERSION='4.0.*@BETA'
42-
- php: hhvm
43-
dist: trusty
40+
- SYMFONY_VERSION='4.0.*'
41+
- php: 7.2
42+
env:
43+
- SYMFONY_VERSION='4.1.*'
4444

4545
before_install:
4646
- phpenv config-rm xdebug.ini || true

DependencyInjection/Configuration.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ class Configuration implements ConfigurationInterface
2424
*/
2525
public function getConfigTreeBuilder()
2626
{
27-
$treeBuilder = new TreeBuilder();
28-
$rootNode = $treeBuilder->root('lunetics_locale');
27+
$treeBuilder = new TreeBuilder('lunetics_locale');
28+
29+
if (method_exists($treeBuilder, 'getRootNode')) {
30+
$rootNode = $treeBuilder->getRootNode();
31+
} else {
32+
$rootNode = $treeBuilder->root('lunetics_locale');
33+
}
2934

3035
$validStatuscodes = array(300, 301, 302, 303, 307);
3136

Tests/Controller/LocaleControllerTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,34 @@
99
*/
1010
namespace Lunetics\LocaleBundle\Tests\Controller;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\HttpFoundation\Request;
1314
use Symfony\Component\HttpFoundation\Session\Session;
1415
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1516

1617
use Lunetics\LocaleBundle\Controller\LocaleController;
1718

18-
class LocaleControllerTest extends \PHPUnit_Framework_TestCase
19+
class LocaleControllerTest extends TestCase
1920
{
2021
public function testControllerThrowsException()
2122
{
2223
$metaValidatorMock = $this->getMetaValidatorMock(false);
2324
$metaValidatorMock->expects($this->atLeastOnce())
24-
->method('isAllowed')
25-
->with($this->anything())
26-
->will($this->returnCallback(function ($v) {
27-
return $v === 'de';
28-
}));
25+
->method('isAllowed')
26+
->with($this->anything())
27+
->will(
28+
$this->returnCallback(
29+
function ($v) {
30+
return $v === 'de';
31+
}
32+
)
33+
);
2934

3035
$request = $this->getRequestWithBrowserPreferences();
3136
$request->setLocale('en');
3237
$localeController = new LocaleController($this->getRouterMock(), $metaValidatorMock);
3338

34-
$this->setExpectedException('\InvalidArgumentException');
39+
$this->expectException('\InvalidArgumentException');
3540
$localeController->switchAction($request);
3641
}
3742

@@ -97,9 +102,9 @@ private function getRouterMock()
97102
{
98103
$routerMock = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->disableOriginalConstructor()->getMock();
99104
$routerMock->expects($this->any())
100-
->method('generate')
101-
->with($this->equalTo('fallback_route'), $this->anything())
102-
->will($this->returnValue('http://fallback_route.com/'));
105+
->method('generate')
106+
->with($this->equalTo('fallback_route'), $this->anything())
107+
->will($this->returnValue('http://fallback_route.com/'));
103108

104109
return $routerMock;
105110
}

Tests/Cookie/LocaleCookieTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
namespace Lunetics\LocaleBundle\Tests\DependencyInjection;
1111

1212
use Lunetics\LocaleBundle\Cookie\LocaleCookie;
13+
use PHPUnit\Framework\TestCase;
1314
use Symfony\Component\HttpFoundation\Cookie;
1415

15-
class LocaleCookieTest extends \PHPUnit_Framework_TestCase
16+
class LocaleCookieTest extends TestCase
1617
{
1718
public function testCookieParamsAreSet()
1819
{

Tests/DependencyInjection/Compiler/GuesserCompilerPassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
namespace Lunetics\LocaleBundle\Tests\DependencyInjection\Compiler;
1111

1212
use Lunetics\LocaleBundle\DependencyInjection\Compiler\GuesserCompilerPass;
13+
use PHPUnit\Framework\TestCase;
1314
use Symfony\Component\DependencyInjection\ContainerBuilder;
1415

1516
/**
1617
* @author Kevin Archer <[email protected]>
1718
*/
18-
class GuesserCompilerPassTest extends \PHPUnit_Framework_TestCase
19+
class GuesserCompilerPassTest extends TestCase
1920
{
2021
public function testProcess()
2122
{

Tests/DependencyInjection/Compiler/RemoveSessionPassTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,28 @@
99
*/
1010
namespace Lunetics\LocaleBundle\Tests\DependencyInjection\Compiler;
1111

12-
use Lunetics\LocaleBundle\DependencyInjection\Compiler\GuesserCompilerPass;
13-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1412
use Lunetics\LocaleBundle\DependencyInjection\Compiler\RemoveSessionPass;
13+
use PHPUnit\Framework\TestCase;
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1515

1616
/**
1717
* @author Asmir Mustafic <[email protected]>
1818
*/
19-
class RemoveSessionPassTest extends \PHPUnit_Framework_TestCase
19+
class RemoveSessionPassTest extends TestCase
2020
{
2121
/**
22-
*
2322
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
2423
*/
25-
private function getContainer(){
24+
private function getContainer()
25+
{
2626
$container = new ContainerBuilder();
2727

2828
$container->register('lunetics_locale.session_guesser');
2929
$container->register('lunetics_locale.locale_session');
30+
3031
return $container;
3132
}
33+
3234
public function testSessionPresent()
3335
{
3436
$container = $this->getContainer();
@@ -39,8 +41,8 @@ public function testSessionPresent()
3941

4042
$this->assertTrue($container->hasDefinition('lunetics_locale.session_guesser'));
4143
$this->assertTrue($container->hasDefinition('lunetics_locale.locale_session'));
42-
4344
}
45+
4446
public function testSessioAbsent()
4547
{
4648
$container = $this->getContainer();
@@ -49,7 +51,6 @@ public function testSessioAbsent()
4951

5052
$this->assertFalse($container->hasDefinition('lunetics_locale.session_guesser'));
5153
$this->assertFalse($container->hasDefinition('lunetics_locale.locale_session'));
52-
5354
}
5455

5556
protected function process(ContainerBuilder $container)

Tests/DependencyInjection/LuneticsLocaleExtensionTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
*/
1010
namespace Lunetics\LocaleBundle\Tests\DependencyInjection;
1111

12-
use Symfony\Component\Config\Resource\FileResource;
13-
use Symfony\Component\Config\Resource\ResourceInterface;
14-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1512
use Lunetics\LocaleBundle\DependencyInjection\LuneticsLocaleExtension;
13+
use PHPUnit\Framework\TestCase;
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1615
use Symfony\Component\Yaml\Parser;
1716

1817
/**
1918
* @author Kevin Archer <[email protected]>
2019
*/
21-
class LuneticsLocaleExtensionTest extends \PHPUnit_Framework_TestCase
20+
class LuneticsLocaleExtensionTest extends TestCase
2221
{
2322
/**
2423
* @dataProvider getFullConfig
@@ -87,7 +86,6 @@ public function testBindParameters()
8786

8887
public function getFullConfig()
8988
{
90-
9189
$parser = new Parser();
9290
$data = array();
9391

@@ -114,7 +112,7 @@ public function getFullConfig()
114112
dutchversion.be: nl_BE
115113
dutch-version.be: nl_BE
116114
EOF;
117-
$data[]=array($parser->parse($yaml), false);
115+
$data[] = array($parser->parse($yaml), false);
118116

119117
$yaml = <<<EOF
120118
lunetics_locale:
@@ -140,7 +138,7 @@ public function getFullConfig()
140138
dutchversion.be: nl_BE
141139
dutch-version.be: nl_BE
142140
EOF;
143-
$data[]=array($parser->parse($yaml), true);
141+
$data[] = array($parser->parse($yaml), true);
144142

145143
return $data;
146144
}

Tests/Event/FilterLocaleSwitchEventTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
namespace Lunetics\LocaleBundle\Tests\Event;
1212

1313
use Lunetics\LocaleBundle\Event\FilterLocaleSwitchEvent;
14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\HttpFoundation\Request;
1516

16-
class FilterLocaleSwitchEventTest extends \PHPUnit_Framework_TestCase
17+
class FilterLocaleSwitchEventTest extends TestCase
1718
{
1819
public function testFilterLocaleSwitchEvent()
1920
{
@@ -29,7 +30,7 @@ public function testFilterLocaleSwitchEvent()
2930
*/
3031
public function testThrowsInvalidTypeException($locale)
3132
{
32-
$this->setExpectedException('\InvalidArgumentException');
33+
$this->expectException('\InvalidArgumentException');
3334
new FilterLocaleSwitchEvent(Request::create('/'), $locale);
3435
}
3536

Tests/EventListener/LocaleListenerTest.php

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@
1010

1111
namespace Lunetics\LocaleBundle\Tests\EventListener;
1212

13-
use Lunetics\LocaleBundle\LocaleGuesser\LocaleGuesserInterface;
13+
use PHPUnit\Framework\TestCase;
1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\EventDispatcher\EventDispatcher;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
1919
use Symfony\Component\HttpFoundation\Session\Session;
2020
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
21-
use Symfony\Component\HttpKernel\HttpKernelInterface;
2221
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
22+
use Symfony\Component\HttpKernel\HttpKernelInterface;
23+
use Symfony\Component\HttpKernel\KernelEvents;
2324

2425
use Lunetics\LocaleBundle\EventListener\LocaleListener;
26+
use Lunetics\LocaleBundle\LocaleBundleEvents;
2527
use Lunetics\LocaleBundle\LocaleGuesser\LocaleGuesserManager;
2628
use Lunetics\LocaleBundle\LocaleGuesser\RouterLocaleGuesser;
2729
use Lunetics\LocaleBundle\LocaleGuesser\BrowserLocaleGuesser;
2830
use Lunetics\LocaleBundle\LocaleGuesser\CookieLocaleGuesser;
2931
use Lunetics\LocaleBundle\LocaleGuesser\QueryLocaleGuesser;
30-
use Lunetics\LocaleBundle\Validator\MetaValidator;
31-
use Lunetics\LocaleBundle\LocaleBundleEvents;
32-
use Symfony\Component\HttpKernel\KernelEvents;
33-
use Lunetics\LocaleBundle\Matcher\DefaultBestLocaleMatcher;
3432
use Lunetics\LocaleBundle\LocaleInformation\AllowedLocalesProvider;
33+
use Lunetics\LocaleBundle\Matcher\DefaultBestLocaleMatcher;
34+
use Lunetics\LocaleBundle\Validator\MetaValidator;
3535

36-
class LocaleListenerTest extends \PHPUnit_Framework_TestCase
36+
class LocaleListenerTest extends TestCase
3737
{
3838
public function testDefaultLocaleWithoutParams()
3939
{
@@ -45,6 +45,7 @@ public function testDefaultLocaleWithoutParams()
4545
$listener->onKernelRequest($event);
4646
$this->assertEquals('fr', $request->getLocale());
4747
}
48+
4849
public function getTestDataForBestLocaleMatcher()
4950
{
5051
return array(
@@ -227,7 +228,8 @@ public function testOnLocaleDetectedSetVaryHeader()
227228
$listener->onLocaleDetectedSetVaryHeader($filterResponseEvent);
228229
}
229230

230-
public function testOnLocaleDetectedDisabledVaryHeader () {
231+
public function testOnLocaleDetectedDisabledVaryHeader()
232+
{
231233
$listener = $this->getListener();
232234
$listener->setDisableVaryHeader(true);
233235

@@ -360,14 +362,6 @@ private function getMockGuesserManager()
360362
return $this->createMock(LocaleGuesserManager::class);
361363
}
362364

363-
/**
364-
* @return LocaleGuesserInterface
365-
*/
366-
private function getMockGuesser()
367-
{
368-
return $this->createMock(LocaleGuesserInterface::class);
369-
}
370-
371365
/**
372366
* @return MetaValidator
373367
*/
@@ -408,11 +402,6 @@ private function getEmptyRequest()
408402
return $request;
409403
}
410404

411-
private function getMockRequest()
412-
{
413-
return $this->createMock(Request::class);
414-
}
415-
416405
private function getMockResponse()
417406
{
418407
return $this->createMock(Response::class);

Tests/EventListener/LocaleUpdateTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@
1010

1111
namespace Lunetics\LocaleBundle\Tests\EventListener;
1212

13-
use Lunetics\LocaleBundle\LocaleBundleEvents;
13+
use PHPUnit\Framework\TestCase;
1414
use Psr\Log\LoggerInterface;
15+
use Symfony\Component\EventDispatcher\EventDispatcher;
1516
use Symfony\Component\HttpFoundation\Session\Session;
17+
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
18+
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1619
use Symfony\Component\HttpKernel\KernelEvents;
1720
use Symfony\Component\HttpKernel\HttpKernelInterface;
1821
use Symfony\Component\HttpFoundation\Request;
19-
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
20-
use Symfony\Component\EventDispatcher\EventDispatcher;
21-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
2222
use Symfony\Component\HttpFoundation\Response;
2323

24+
use Lunetics\LocaleBundle\Cookie\LocaleCookie;
2425
use Lunetics\LocaleBundle\Event\FilterLocaleSwitchEvent;
2526
use Lunetics\LocaleBundle\EventListener\LocaleUpdateListener;
27+
use Lunetics\LocaleBundle\LocaleBundleEvents;
2628
use Lunetics\LocaleBundle\Session\LocaleSession;
27-
use Lunetics\LocaleBundle\Cookie\LocaleCookie;
2829

29-
class LocaleUpdateTest extends \PHPUnit_Framework_TestCase
30+
class LocaleUpdateTest extends TestCase
3031
{
3132
/**
3233
* @var EventDispatcher

0 commit comments

Comments
 (0)