Skip to content

use phpunit 8 #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="8" />
</php>

<testsuites>
Expand All @@ -29,9 +29,11 @@

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<extensions>
<!-- it begins a database transaction before every testcase and rolls it back after
the test finished, so tests can manipulate the database without affecting other tests -->
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitListener" />
</listeners>
the test finished, so tests can manipulate the database without affecting other tests -->
<extension class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
30 changes: 14 additions & 16 deletions tests/Utils/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,89 +16,87 @@

class ValidatorTest extends TestCase
{
private $object;
private $validator;

public function __construct()
protected function setUp(): void
{
parent::__construct();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused

Other deprecation notices (1)

  1x: The "PHPUnit\Framework\TestCase::__construct()" method is considered internal This method is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not extend it from "App\Tests\Utils\ValidatorTest".


$this->object = new Validator();
$this->validator = new Validator();
}

public function testValidateUsername()
{
$test = 'username';

$this->assertSame($test, $this->object->validateUsername($test));
$this->assertSame($test, $this->validator->validateUsername($test));
}

public function testValidateUsernameEmpty()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The username can not be empty.');
$this->object->validateUsername(null);
$this->validator->validateUsername(null);
}

public function testValidateUsernameInvalid()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The username must contain only lowercase latin characters and underscores.');
$this->object->validateUsername('INVALID');
$this->validator->validateUsername('INVALID');
}

public function testValidatePassword()
{
$test = 'password';

$this->assertSame($test, $this->object->validatePassword($test));
$this->assertSame($test, $this->validator->validatePassword($test));
}

public function testValidatePasswordEmpty()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The password can not be empty.');
$this->object->validatePassword(null);
$this->validator->validatePassword(null);
}

public function testValidatePasswordInvalid()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The password must be at least 6 characters long.');
$this->object->validatePassword('12345');
$this->validator->validatePassword('12345');
}

public function testValidateEmail()
{
$test = '@';

$this->assertSame($test, $this->object->validateEmail($test));
$this->assertSame($test, $this->validator->validateEmail($test));
}

public function testValidateEmailEmpty()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The email can not be empty.');
$this->object->validateEmail(null);
$this->validator->validateEmail(null);
}

public function testValidateEmailInvalid()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The email should look like a real email.');
$this->object->validateEmail('invalid');
$this->validator->validateEmail('invalid');
}

public function testValidateFullName()
{
$test = 'Full Name';

$this->assertSame($test, $this->object->validateFullName($test));
$this->assertSame($test, $this->validator->validateFullName($test));
}

public function testValidateFullNameEmpty()
{
$this->expectException('Exception');
$this->expectExceptionMessage('The full name can not be empty.');
$this->object->validateFullName(null);
$this->validator->validateFullName(null);
}
}