1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Task\TaskBundle\Tests\Functional\Entity; |
4
|
|
|
|
5
|
|
|
use Task\TaskBundle\Entity\TaskRepository; |
6
|
|
|
use Task\TaskBundle\Tests\Functional\BaseDatabaseTestCase; |
7
|
|
|
|
8
|
|
|
class TaskRepositoryTest extends BaseDatabaseTestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var TaskRepository |
12
|
|
|
*/ |
13
|
|
|
protected $taskRepository; |
14
|
|
|
|
15
|
|
|
public function setUp() |
16
|
|
|
{ |
17
|
|
|
parent::setUp(); |
18
|
|
|
|
19
|
|
|
$this->taskRepository = self::$kernel->getContainer()->get('task.storage.task'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testFindBySystemKey() |
23
|
|
|
{ |
24
|
|
|
if (self::$kernel->getContainer()->getParameter('kernel.storage') !== 'doctrine') { |
25
|
|
|
return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$task = $this->createTask(); |
29
|
|
|
$task->setSystemKey('test'); |
30
|
|
|
|
31
|
|
|
$this->taskRepository->save($task); |
32
|
|
|
|
33
|
|
|
$result = $this->taskRepository->findBySystemKey('test'); |
34
|
|
|
$this->assertEquals($task->getUuid(), $result->getUuid()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testFindBySystemKeyNotFound() |
38
|
|
|
{ |
39
|
|
|
if (self::$kernel->getContainer()->getParameter('kernel.storage') !== 'doctrine') { |
40
|
|
|
return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$task = $this->createTask(); |
44
|
|
|
$this->taskRepository->save($task); |
45
|
|
|
|
46
|
|
|
$this->assertNull($this->taskRepository->findBySystemKey('test')); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testFindSystemTasks() |
50
|
|
|
{ |
51
|
|
|
if (self::$kernel->getContainer()->getParameter('kernel.storage') !== 'doctrine') { |
52
|
|
|
return $this->markTestSkipped('This testcase will only be called for doctrine storage.'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$task1 = $this->createTask(); |
56
|
|
|
$task1->setSystemKey('test'); |
57
|
|
|
$this->taskRepository->save($task1); |
58
|
|
|
|
59
|
|
|
$task2 = $this->createTask(); |
60
|
|
|
$this->taskRepository->save($task2); |
61
|
|
|
|
62
|
|
|
$result = $this->taskRepository->findSystemTasks(); |
63
|
|
|
$this->assertCount(1, $result); |
64
|
|
|
$this->assertEquals($task1->getUuid(), $result[0]->getUuid()); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|