-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNewsRepositoryTest.php
More file actions
76 lines (59 loc) · 1.76 KB
/
Copy pathNewsRepositoryTest.php
File metadata and controls
76 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php declare(strict_types=1);
namespace App\Tests\Functional\Repository;
use App\Entity\News;
use App\Repository\NewsRepository;
use App\Tests\Shared\Functional\RepositoryWebTestCase;
class NewsRepositoryTest extends RepositoryWebTestCase
{
const COUNT_ALL = 3;
const COUNT_PUBLISHED = 2;
const WRONG_SLUG = '__x_x_x__';
protected function getRepositoryClass()
{
return NewsRepository::class;
}
public function testFindAll()
{
// Act
$news = $this->repository->findAll();
// Assert
$this->assertCount(self::COUNT_ALL, $news);
}
public function testFindAllPublished()
{
// Act
$news = $this->repository->findAllPublished();
// Assert
$this->assertCount(self::COUNT_PUBLISHED, $news);
}
public function testFindOnePublishedBySlug()
{
// Arrange
$news = $this->fixtures()->news('news_published_1');
$slug = $news->getSlug();
// Act
$news = $this->repository->findOnePublishedBySlug($slug);
// Assert
$this->assertInstanceOf(News::class, $news);
$this->assertSame($slug, $news->getSlug());
}
public function testFindOnePublishedWithWrongSlugReturnsNull()
{
// Arrange
$slug = self::WRONG_SLUG;
// Act
$news = $this->repository->findOnePublishedBySlug($slug);
// Assert
$this->assertNull($news);
}
public function testFindOnePublishedWithNotPublishedNewsReturnsNull()
{
// Arrange
$news = $this->fixtures()->news('news_not_published_1');
$slug = $news->getSlug();
// Act
$news = $this->repository->findOnePublishedBySlug($slug);
// Assert
$this->assertNull($news);
}
}