Only count published daily emails
This commit is contained in:
parent
c48f8acd4a
commit
b479e15b66
2 changed files with 10 additions and 5 deletions
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Drupal\opd_daily_emails\Repository;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
||||
|
||||
|
@ -18,7 +19,7 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
|||
->getStorage('node')
|
||||
->getQuery();
|
||||
|
||||
// TODO: add condition for published status. Only return published nodes.
|
||||
$query->condition('status', NodeInterface::PUBLISHED);
|
||||
$query->condition('type', 'daily_email');
|
||||
|
||||
$query->accessCheck(TRUE);
|
||||
|
|
|
@ -19,12 +19,16 @@ final class DailyEmailNodeRepositoryTest extends EntityKernelTestBase {
|
|||
'opd_daily_emails',
|
||||
];
|
||||
|
||||
/**
|
||||
* @testdox Get all daily emails
|
||||
*/
|
||||
public function test_get_all(): void {
|
||||
public function test_get_all_published_daily_emails(): void {
|
||||
$this->createNode([
|
||||
'status' => NodeInterface::PUBLISHED,
|
||||
'title' => 'A published daily email',
|
||||
'type' => 'daily_email',
|
||||
]);
|
||||
|
||||
$this->createNode([
|
||||
'status' => NodeInterface::NOT_PUBLISHED,
|
||||
'title' => 'An unpublished daily email',
|
||||
'type' => 'daily_email',
|
||||
]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue