Skip to content
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
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},

"require-dev": {
"doctrine/common": "^2.0 | ^3.0",
"doctrine/doctrine-bundle": "^3.0",
"phpunit/phpunit": "^11.0",
"symfony/browser-kit": "^8.0",
Expand Down
44 changes: 19 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
colors="true">

<php>
<ini name="error_reporting" value="-1" />
<server name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
<env name="KERNEL_CLASS" value="Webfactory\NewsletterRegistrationBundle\Tests\Fixtures\Kernel"/>
<env name="APP_ENV" value="test"/>
<env name="APP_DEBUG" value="0"/>
</php>

<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>

<testsuites>
<testsuite name="App Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" colors="true">
<php>
<ini name="error_reporting" value="-1"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
<env name="KERNEL_CLASS" value="Webfactory\NewsletterRegistrationBundle\Tests\Fixtures\Kernel"/>
<env name="APP_ENV" value="test"/>
<env name="APP_DEBUG" value="0"/>
</php>
<testsuites>
<testsuite name="App Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
17 changes: 5 additions & 12 deletions tests/BlockEmails/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\BlockEmails;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Webfactory\NewsletterRegistrationBundle\BlockEmails\Task;
Expand Down Expand Up @@ -37,9 +38,7 @@ protected function setUp(): void
);
}

/**
* @test
*/
#[Test]
public function throws_exception_if_email_address_does_not_match_hash()
{
$pendingOptIn = new PendingOptIn('uuid', $this->emailAddressFactory->fromString('webfactory@example.com'));
Expand All @@ -48,9 +47,7 @@ public function throws_exception_if_email_address_does_not_match_hash()
$this->task->blockEmailsFor($pendingOptIn, 'other@example.com');
}

/**
* @test
*/
#[Test]
public function saves_block()
{
$this->blockedEmailHashesRepository->expects($this->once())->method('save');
Expand All @@ -59,9 +56,7 @@ public function saves_block()
$this->task->blockEmailsFor($pendingOptIn, 'webfactory@example.com');
}

/**
* @test
*/
#[Test]
public function replaces_older_block_if_it_exists()
{
$emailAddress = $this->emailAddressFactory->fromString('webfactory@example.com');
Expand All @@ -85,9 +80,7 @@ public function replaces_older_block_if_it_exists()
$this->task->blockEmailsFor($pendingOptIn, 'webfactory@example.com');
}

/**
* @test
*/
#[Test]
public function removes_PendingOpIn()
{
$pendingOptIn = new PendingOptIn('uuid', $this->emailAddressFactory->fromString('webfactory@example.com'));
Expand Down
21 changes: 6 additions & 15 deletions tests/ConfirmRegistration/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webfactory\NewsletterRegistrationBundle\Tests\ConfirmRegistration;

use DateTimeImmutable;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -57,9 +58,7 @@ protected function setUp(): void
);
}

/**
* @test
*/
#[Test]
public function throws_exception_if_PendingOptIn_is_outdated()
{
$pendingOptIn = new PendingOptIn(
Expand All @@ -73,9 +72,7 @@ public function throws_exception_if_PendingOptIn_is_outdated()
$this->task->confirmRegistration($pendingOptIn, 'other@example.com');
}

/**
* @test
*/
#[Test]
public function throws_exception_if_email_address_does_not_match_hash()
{
$pendingOptIn = new PendingOptIn('uuid', $this->emailAddressFactory->fromString('webfactory@example.com'));
Expand All @@ -84,9 +81,7 @@ public function throws_exception_if_email_address_does_not_match_hash()
$this->task->confirmRegistration($pendingOptIn, 'other@example.com');
}

/**
* @test
*/
#[Test]
public function saves_recipient()
{
$this->recipientRepo->expects($this->once())->method('save');
Expand All @@ -95,9 +90,7 @@ public function saves_recipient()
$this->task->confirmRegistration($pendingOptIn, 'webfactory@example.com');
}

/**
* @test
*/
#[Test]
public function removes_pending_opt_in()
{
$pendingOptIn = new PendingOptIn('uuid', $this->emailAddressFactory->fromString('webfactory@example.com'));
Expand All @@ -106,9 +99,7 @@ public function removes_pending_opt_in()
$this->task->confirmRegistration($pendingOptIn, 'webfactory@example.com');
}

/**
* @test
*/
#[Test]
public function writes_success_flash()
{
$pendingOptIn = new PendingOptIn('uuid', $this->emailAddressFactory->fromString('webfactory@example.com'));
Expand Down
9 changes: 3 additions & 6 deletions tests/DeleteOutdatedBlockedEmailAddresses/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webfactory\NewsletterRegistrationBundle\Tests\DeleteOutdatedBlockedEmailAddresses;

use DateTimeImmutable;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Webfactory\NewsletterRegistrationBundle\DeleteOutdatedPendingOptIns\Task;
Expand All @@ -23,9 +24,7 @@ protected function setUp(): void
$this->task = new Task($this->repository, self::BLOCK_EMAIL_DURATION_IN_DAYS);
}

/**
* @test
*/
#[Test]
public function delegates_to_repository(): void
{
$this->repository
Expand All @@ -35,9 +34,7 @@ public function delegates_to_repository(): void
$this->task->deleteOutdatedPendingOptIns();
}

/**
* @test
*/
#[Test]
public function sets_threshold_date_from_now_if_called_without_one(): void
{
$expected = new DateTimeImmutable('-'.self::BLOCK_EMAIL_DURATION_IN_DAYS.' hour');
Expand Down
9 changes: 3 additions & 6 deletions tests/DeleteOutdatedPendingOptIns/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webfactory\NewsletterRegistrationBundle\Tests\DeleteOutdatedPendingOptIns;

use DateTimeImmutable;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Webfactory\NewsletterRegistrationBundle\DeleteOutdatedPendingOptIns\Task;
Expand All @@ -23,9 +24,7 @@ protected function setUp(): void
$this->task = new Task($this->repository, self::TIME_LIMIT_FOR_OPT_IN_IN_HOURS);
}

/**
* @test
*/
#[Test]
public function delegates_to_repository(): void
{
$this->repository
Expand All @@ -35,9 +34,7 @@ public function delegates_to_repository(): void
$this->task->deleteOutdatedPendingOptIns();
}

/**
* @test
*/
#[Test]
public function sets_threshold_date_from_now_if_called_without_one(): void
{
$expected = new DateTimeImmutable('-'.self::TIME_LIMIT_FOR_OPT_IN_IN_HOURS.' hour');
Expand Down
9 changes: 3 additions & 6 deletions tests/DeleteRegistration/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\DeleteRegistration;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -35,9 +36,7 @@ protected function setUp(): void
$this->task = new Task($this->recipientRepo, $this->requestStack, $this->translator);
}

/**
* @test
*/
#[Test]
public function removes_recipient()
{
$recipient = new Recipient('uuid', new EmailAddress('webfactory@example.com', null));
Expand All @@ -46,9 +45,7 @@ public function removes_recipient()
$this->task->deleteRegistration($recipient);
}

/**
* @test
*/
#[Test]
public function writes_success_flash()
{
$recipient = new Recipient('uuid', new EmailAddress('webfactory@example.com', null));
Expand Down
5 changes: 2 additions & 3 deletions tests/EditRegistration/SendLinkTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\StartRegistration;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Mailer\MailerInterface;
Expand Down Expand Up @@ -30,9 +31,7 @@ protected function setUp(): void
$this->task = new SendLinkTask($this->mailer, self::SENDER, $this->twig, $this->urlGenerator);
}

/**
* @test
*/
#[Test]
public function sends_edit_registration_email()
{
$recipient = new Recipient(null, new EmailAddress('receiver@example.com', null));
Expand Down
9 changes: 3 additions & 6 deletions tests/EditRegistration/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Webfactory\NewsletterRegistrationBundle\Tests\EditRegistration;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -35,9 +36,7 @@ protected function setUp(): void
$this->task = new Task($this->recipientRepo, $this->requestStack, $this->translator);
}

/**
* @test
*/
#[Test]
public function saves_recipient()
{
$recipient = new Recipient('uuid', new EmailAddress('webfactory@example.com', null));
Expand All @@ -46,9 +45,7 @@ public function saves_recipient()
$this->task->editRegistration($recipient);
}

/**
* @test
*/
#[Test]
public function writes_success_flash()
{
$recipient = new Recipient('uuid', new EmailAddress('webfactory@example.com', null));
Expand Down
17 changes: 5 additions & 12 deletions tests/Entity/BlockedEmailAddressHashRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webfactory\NewsletterRegistrationBundle\Tests\Entity;

use DateTimeImmutable;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Webfactory\NewsletterRegistrationBundle\Entity\BlockedEmailAddressHash;
use Webfactory\NewsletterRegistrationBundle\Entity\BlockedEmailAddressHashRepositoryInterface;
Expand All @@ -27,9 +28,7 @@ protected function setUp(): void
->getRepository(BlockedEmailAddressHash::class);
}

/**
* @test
*/
#[Test]
public function findByEmailAddress_returns_BlockedEmailAddressHash_if_it_exists(): void
{
$emailAddress = new EmailAddress('webfactory@example.com', 'secret');
Expand All @@ -38,19 +37,15 @@ public function findByEmailAddress_returns_BlockedEmailAddressHash_if_it_exists(
$this->assertNotEmpty($this->repository->findByEmailAddress($emailAddress));
}

/**
* @test
*/
#[Test]
public function findByEmailAddress_returns_null_if_no_matching_BlockedEmailAddressHash_exists(): void
{
$this->assertNull(
$this->repository->findByEmailAddress(new EmailAddress('webfactory@example.com', 'secret'))
);
}

/**
* @test
*/
#[Test]
public function removeOutdated_removes_outdated_ones(): void
{
BlockedEmailAddressHashFactory::createOne(['blockDate' => new DateTimeImmutable('2000-01-01')]);
Expand All @@ -61,9 +56,7 @@ public function removeOutdated_removes_outdated_ones(): void
$this->assertCount(0, $this->repository->findAll());
}

/**
* @test
*/
#[Test]
public function removeOutdated_does_not_remove_current_ones(): void
{
BlockedEmailAddressHashFactory::createOne(['blockDate' => new DateTimeImmutable('-1d')]);
Expand Down
Loading
Loading