Skip to content

Commit e76db6a

Browse files
committed
Allow PHP8 and use phpunit-bridge to run tests
1 parent e42555d commit e76db6a

17 files changed

+96
-100
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: CI
33
on:
44
pull_request:
55
push:
6-
branches: [ master ]
6+
branches:
7+
- master
8+
- 2.x
79

810
jobs:
911
run:
@@ -18,6 +20,7 @@ jobs:
1820
- '7.2'
1921
- '7.3'
2022
- '7.4'
23+
- '8.0'
2124
symfony-versions: [false]
2225
include:
2326
- description: 'Symfony 2.*'
@@ -52,4 +55,6 @@ jobs:
5255
run: composer install
5356

5457
- name: Run PHPUnit tests
55-
run: ./vendor/bin/phpunit --coverage-text
58+
run: |
59+
export SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1
60+
./vendor/bin/simple-phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
composer.lock
44
phpunit.xml
55
vendor/
6+
.phpunit.result.cache

Tests/Command/ActivateUserCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testExecute()
3030
]);
3131

3232
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
33-
$this->assertRegExp('/User "user" has been activated/', $commandTester->getDisplay());
33+
$this->assertMatchesRegularExpression('/User "user" has been activated/', $commandTester->getDisplay());
3434
}
3535

3636
public function testExecuteInteractiveWithQuestionHelper()
@@ -41,7 +41,7 @@ public function testExecuteInteractiveWithQuestionHelper()
4141
->setMethods(['ask'])
4242
->getMock();
4343

44-
$helper->expects($this->at(0))
44+
$helper
4545
->method('ask')
4646
->will($this->returnValue('user'));
4747

@@ -54,7 +54,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5454
]);
5555

5656
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
57-
$this->assertRegExp('/User "user" has been activated/', $commandTester->getDisplay());
57+
$this->assertMatchesRegularExpression('/User "user" has been activated/', $commandTester->getDisplay());
5858
}
5959

6060
/**

Tests/Command/ChangePasswordCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testExecute()
3131
]);
3232

3333
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
34-
$this->assertRegExp('/Changed password for user user/', $commandTester->getDisplay());
34+
$this->assertMatchesRegularExpression('/Changed password for user user/', $commandTester->getDisplay());
3535
}
3636

3737
public function testExecuteInteractiveWithQuestionHelper()
@@ -58,7 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5858
]);
5959

6060
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
61-
$this->assertRegExp('/Changed password for user user/', $commandTester->getDisplay());
61+
$this->assertMatchesRegularExpression('/Changed password for user user/', $commandTester->getDisplay());
6262
}
6363

6464
/**

Tests/Command/CreateUserCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testExecute()
3232
]);
3333

3434
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
35-
$this->assertRegExp('/Created user user/', $commandTester->getDisplay());
35+
$this->assertMatchesRegularExpression('/Created user user/', $commandTester->getDisplay());
3636
}
3737

3838
public function testExecuteInteractiveWithQuestionHelper()
@@ -66,7 +66,7 @@ public function testExecuteInteractiveWithQuestionHelper()
6666
]);
6767

6868
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
69-
$this->assertRegExp('/Created user user/', $commandTester->getDisplay());
69+
$this->assertMatchesRegularExpression('/Created user user/', $commandTester->getDisplay());
7070
}
7171

7272
/**

Tests/Command/DeactivateUserCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testExecute()
3030
]);
3131

3232
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
33-
$this->assertRegExp('/User "user" has been deactivated/', $commandTester->getDisplay());
33+
$this->assertMatchesRegularExpression('/User "user" has been deactivated/', $commandTester->getDisplay());
3434
}
3535

3636
public function testExecuteInteractiveWithQuestionHelper()
@@ -54,7 +54,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5454
]);
5555

5656
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
57-
$this->assertRegExp('/User "user" has been deactivated/', $commandTester->getDisplay());
57+
$this->assertMatchesRegularExpression('/User "user" has been deactivated/', $commandTester->getDisplay());
5858
}
5959

6060
/**

Tests/Command/DemoteUserCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testExecute()
3131
]);
3232

3333
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
34-
$this->assertRegExp('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
34+
$this->assertMatchesRegularExpression('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
3535
}
3636

3737
public function testExecuteInteractiveWithQuestionHelper()
@@ -58,7 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5858
]);
5959

6060
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
61-
$this->assertRegExp('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
61+
$this->assertMatchesRegularExpression('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
6262
}
6363

6464
/**

Tests/Command/PromoteUserCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testExecute()
3131
]);
3232

3333
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
34-
$this->assertRegExp('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
34+
$this->assertMatchesRegularExpression('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
3535
}
3636

3737
public function testExecuteInteractiveWithQuestionHelper()
@@ -58,7 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5858
]);
5959

6060
$this->assertSame(0, $exitCode, 'Returns 0 in case of success');
61-
$this->assertRegExp('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
61+
$this->assertMatchesRegularExpression('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
6262
}
6363

6464
/**

Tests/DependencyInjection/FOSUserExtensionTest.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use FOS\UserBundle\DependencyInjection\FOSUserExtension;
1515
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\Yaml\Parser;
1819

@@ -26,68 +27,63 @@ protected function tearDown()
2627
$this->configuration = null;
2728
}
2829

29-
/**
30-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
31-
*/
3230
public function testUserLoadThrowsExceptionUnlessDatabaseDriverSet()
3331
{
32+
$this->expectException(InvalidConfigurationException::class);
33+
3434
$loader = new FOSUserExtension();
3535
$config = $this->getEmptyConfig();
3636
unset($config['db_driver']);
3737
$loader->load([$config], new ContainerBuilder());
3838
}
3939

40-
/**
41-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
42-
*/
4340
public function testUserLoadThrowsExceptionUnlessDatabaseDriverIsValid()
4441
{
42+
$this->expectException(InvalidConfigurationException::class);
43+
4544
$loader = new FOSUserExtension();
4645
$config = $this->getEmptyConfig();
4746
$config['db_driver'] = 'foo';
4847
$loader->load([$config], new ContainerBuilder());
4948
}
5049

51-
/**
52-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
53-
*/
5450
public function testUserLoadThrowsExceptionUnlessFirewallNameSet()
5551
{
52+
$this->expectException(InvalidConfigurationException::class);
53+
5654
$loader = new FOSUserExtension();
5755
$config = $this->getEmptyConfig();
5856
unset($config['firewall_name']);
5957
$loader->load([$config], new ContainerBuilder());
6058
}
6159

6260
/**
63-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
64-
*
6561
* @group legacy
6662
*/
6763
public function testUserLoadThrowsExceptionUnlessGroupModelClassSet()
6864
{
65+
$this->expectException(InvalidConfigurationException::class);
66+
6967
$loader = new FOSUserExtension();
7068
$config = $this->getFullConfig();
7169
unset($config['group']['group_class']);
7270
$loader->load([$config], new ContainerBuilder());
7371
}
7472

75-
/**
76-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
77-
*/
7873
public function testUserLoadThrowsExceptionUnlessUserModelClassSet()
7974
{
75+
$this->expectException(InvalidConfigurationException::class);
76+
8077
$loader = new FOSUserExtension();
8178
$config = $this->getEmptyConfig();
8279
unset($config['user_class']);
8380
$loader->load([$config], new ContainerBuilder());
8481
}
8582

86-
/**
87-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
88-
*/
8983
public function testCustomDriverWithoutManager()
9084
{
85+
$this->expectException(InvalidConfigurationException::class);
86+
9187
$loader = new FOSUserExtension();
9288
$config = $this->getEmptyConfig();
9389
$config['db_driver'] = 'custom';

Tests/Mailer/MailerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ public function testSendConfirmationEmailMessageWithGoodEmails($emailAddress)
3131

3232
/**
3333
* @dataProvider badEmailProvider
34-
* @expectedException \Swift_RfcComplianceException
3534
*/
3635
public function testSendConfirmationEmailMessageWithBadEmails($emailAddress)
3736
{
37+
$this->expectException(\Swift_RfcComplianceException::class);
38+
3839
$mailer = $this->getMailer();
3940
$mailer->sendConfirmationEmailMessage($this->getUser($emailAddress));
4041
}
@@ -52,10 +53,11 @@ public function testSendResettingEmailMessageWithGoodEmails($emailAddress)
5253

5354
/**
5455
* @dataProvider badEmailProvider
55-
* @expectedException \Swift_RfcComplianceException
5656
*/
5757
public function testSendResettingEmailMessageWithBadEmails($emailAddress)
5858
{
59+
$this->expectException(\Swift_RfcComplianceException::class);
60+
5961
$mailer = $this->getMailer();
6062
$mailer->sendResettingEmailMessage($this->getUser($emailAddress));
6163
}

0 commit comments

Comments
 (0)