-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Bundle/test/src/Subscription/Repository/SubscriptionRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Subscription\Repository; | ||
|
||
use App\Subscription\Entity\Subscription; | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\ORM\QueryBuilder; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\ResourceRepositoryTrait; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
|
||
final class SubscriptionRepository extends ServiceEntityRepository implements RepositoryInterface | ||
{ | ||
use ResourceRepositoryTrait; | ||
|
||
public function __construct(ManagerRegistry $registry) | ||
{ | ||
parent::__construct($registry, Subscription::class); | ||
} | ||
|
||
public function createListQueryBuilder(bool $showArchived = false): QueryBuilder | ||
{ | ||
$queryBuilder = $this->createQueryBuilder('o'); | ||
|
||
if (!$showArchived) { | ||
$queryBuilder->andWhere( | ||
$queryBuilder->expr()->isNull('o.archivedAt'), | ||
); | ||
} | ||
|
||
return $queryBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,11 @@ public function it_allows_browsing_subscriptions(): void | |
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s">Show</a>', $subscriptions['subscription_doc']->getId()), $content); | ||
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s/edit">Edit</a>', $subscriptions['subscription_doc']->getId()), $content); | ||
$this->assertStringContainsString(sprintf('<form action="/admin/subscriptions/%s" method="post">', $subscriptions['subscription_doc']->getId()), $content); | ||
|
||
$this->assertStringContainsString('<td>[email protected]</td>', $content); | ||
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s">Show</a>', $subscriptions['subscription_archived']->getId()), $content); | ||
$this->assertStringContainsString(sprintf('<a href="/admin/subscriptions/%s/edit">Edit</a>', $subscriptions['subscription_archived']->getId()), $content); | ||
$this->assertStringContainsString(sprintf('<form action="/admin/subscriptions/%s" method="post">', $subscriptions['subscription_archived']->getId()), $content); | ||
} | ||
|
||
/** @test */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ App\Subscription\Entity\Subscription: | |
email: '[email protected]' | ||
subscription_doc: | ||
email: '[email protected]' | ||
subscription_archived: | ||
email: '[email protected]' | ||
archivedAt: '<dateTimeBetween("-200 days", "now")>' |