Skip to content

Commit 4cc4f1a

Browse files
committed
it works on my machine
1 parent d955fa9 commit 4cc4f1a

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/vendor/
55
/.php_cs.cache
66
symfony.lock
7+
.phpunit.result.cache

tests/Blacklist/SqliteProviderTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
16+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1617

1718
class SqliteProviderTest extends TestCase
1819
{
20+
use SetUpTearDownTrait;
21+
1922
/**
2023
* @var string
2124
*/
@@ -26,7 +29,7 @@ class SqliteProviderTest extends TestCase
2629
*/
2730
protected static $provider;
2831

29-
public static function setUpBeforeClass()
32+
public static function doSetUpBeforeClass()
3033
{
3134
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
3235
self::markTestSkipped('This test requires SQLite support in your environment');
@@ -40,7 +43,7 @@ public static function setUpBeforeClass()
4043
self::$provider = new SqliteProvider('sqlite:'.self::$dbFile);
4144
}
4245

43-
public static function tearDownAfterClass()
46+
public static function doTearDownAfterClass()
4447
{
4548
@unlink(self::$dbFile);
4649
}
@@ -84,7 +87,7 @@ public function testPurge()
8487
self::assertTrue(self::$provider->isBlacklisted('test'));
8588
}
8689

87-
protected function setUp()
90+
protected function doSetUp()
8891
{
8992
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
9093
$this->markTestSkipped('This test requires SQLite support in your environment');

tests/Command/BlacklistCommandTestCase.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
1616
use Rollerworks\Component\PasswordStrength\Tests\BlackListMockProviderTrait;
17+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1718

1819
abstract class BlacklistCommandTestCase extends TestCase
1920
{
2021
use BlackListMockProviderTrait;
22+
use SetUpTearDownTrait;
2123

2224
protected static $dbFile;
2325
protected static $storage;
@@ -27,7 +29,7 @@ abstract class BlacklistCommandTestCase extends TestCase
2729
*/
2830
protected static $blackListProvider;
2931

30-
public static function setUpBeforeClass()
32+
public static function doSetUpBeforeClass()
3133
{
3234
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
3335
self::markTestSkipped('This test requires SQLite support in your environment');
@@ -41,12 +43,12 @@ public static function setUpBeforeClass()
4143
self::$blackListProvider = new SqliteProvider('sqlite:'.self::$dbFile);
4244
}
4345

44-
public static function tearDownAfterClass()
46+
public static function doTearDownAfterClass()
4547
{
4648
@unlink(self::$dbFile);
4749
}
4850

49-
protected function setUp()
51+
protected function doSetUp()
5052
{
5153
self::$blackListProvider->purge();
5254
}

tests/P0wnedPassword/Request/ClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
use Psr\Log\NullLogger;
2020
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Client;
2121
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Result;
22+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
2223

2324
class ClientTest extends TestCase
2425
{
26+
use SetUpTearDownTrait;
27+
2528
/** @var HttpClient|MockObject */
2629
private $client;
2730

@@ -56,7 +59,7 @@ class ClientTest extends TestCase
5659
0C341F894BD4EE961AE874ACD3BC8157825:4
5760
';
5861

59-
public function setUp()
62+
public function doSetUp()
6063
{
6164
$this->client = $this->createMock(HttpClient::class);
6265
$this->checker = new Client($this->client, new NullLogger());

tests/Validator/BlacklistValidationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Rollerworks\Component\PasswordStrength\Validator\Constraints\Blacklist;
1717
use Rollerworks\Component\PasswordStrength\Validator\Constraints\BlacklistValidator;
1818
use Symfony\Component\Validator\Exception\RuntimeException;
19+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1920
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2021

2122
class BlacklistValidationTest extends ConstraintValidatorTestCase
@@ -63,11 +64,10 @@ public function testEmptyStringIsValid()
6364
$this->assertNoViolation();
6465
}
6566

66-
/**
67-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
68-
*/
6967
public function testExpectsStringCompatibleType()
7068
{
69+
$this->expectException(UnexpectedTypeException::class);
70+
7171
$this->validator->validate(new \stdClass(), new Blacklist());
7272
}
7373

tests/Validator/P0wnedPasswordValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@
1616
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Result;
1717
use Rollerworks\Component\PasswordStrength\Validator\Constraints\P0wnedPassword;
1818
use Rollerworks\Component\PasswordStrength\Validator\Constraints\P0wnedPasswordValidator;
19+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1920
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2021

2122
class P0wnedPasswordValidatorTest extends ConstraintValidatorTestCase
2223
{
24+
use SetUpTearDownTrait;
25+
2326
/** @var Client|MockObject */
2427
private $client;
2528

2629
/** @var P0wnedPasswordValidator */
2730
protected $validator;
2831

29-
public function setUp(): void
32+
public function doSetUp(): void
3033
{
3134
$this->client = $this->createMock(Client::class);
3235
parent::setUp();

tests/Validator/PasswordStrengthTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordStrength;
1515
use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordStrengthValidator;
1616
use Symfony\Component\Translation\Translator;
17+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1819

1920
class PasswordStrengthTest extends ConstraintValidatorTestCase
@@ -68,11 +69,10 @@ public function testEmptyIsValid()
6869
$this->assertNoViolation();
6970
}
7071

71-
/**
72-
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
73-
*/
7472
public function testExpectsStringCompatibleType()
7573
{
74+
$this->expectException(UnexpectedTypeException::class);
75+
7676
$this->validator->validate(new \stdClass(), new PasswordStrength(5));
7777
}
7878

0 commit comments

Comments
 (0)