Skip to content

Commit 6e5a010

Browse files
fixed test-cases and removed old ones
1 parent e165285 commit 6e5a010

File tree

11 files changed

+94
-391
lines changed

11 files changed

+94
-391
lines changed

src/DoctrineStorage/TaskRepository.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function __construct(ObjectManager $objectManager, ORMTaskRepository $tas
4747
public function store(TaskInterface $task)
4848
{
4949
$this->objectManager->persist($task);
50+
51+
// FIXME move this flush to somewhere else (:
5052
$this->objectManager->flush();
5153
}
5254

@@ -65,4 +67,17 @@ public function findEndBeforeNow()
6567
{
6668
return $this->taskRepository->findEndBefore(new \DateTime());
6769
}
70+
71+
/**
72+
* {@inheritdoc}
73+
*/
74+
public function clear()
75+
{
76+
foreach ($this->taskRepository->findAll() as $task) {
77+
$this->objectManager->remove($task);
78+
}
79+
80+
// FIXME move this flush to somewhere else (:
81+
$this->objectManager->flush();
82+
}
6883
}

tests/Functional/BootstrapTest.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<?php
22

3+
/*
4+
* This file is part of php-task library.
5+
*
6+
* (c) php-task
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Functional;
413

514
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6-
use Task\SchedulerInterface;
7-
use Task\Storage\ArrayStorage;
8-
use Task\TaskBundle\Storage\DoctrineStorage;
15+
use Task\Scheduler\SchedulerInterface;
16+
use Task\Storage\ArrayStorage\ArrayTaskExecutionRepository;
17+
use Task\Storage\ArrayStorage\ArrayTaskRepository;
18+
use Task\TaskBundle\DoctrineStorage\TaskExecutionRepository;
19+
use Task\TaskBundle\DoctrineStorage\TaskRepository;
920

1021
class BootstrapTest extends KernelTestCase
1122
{
@@ -14,16 +25,19 @@ public function testBootstrap()
1425
$this->bootKernel();
1526

1627
$scheduler = self::$kernel->getContainer()->get('task.scheduler');
17-
$storage = self::$kernel->getContainer()->get('task.storage');
28+
$taskRepository = self::$kernel->getContainer()->get('task.storage.task');
29+
$taskExecutionRepository = self::$kernel->getContainer()->get('task.storage.task_execution');
1830

1931
$this->assertInstanceOf(SchedulerInterface::class, $scheduler);
2032

2133
switch (self::$kernel->getContainer()->getParameter('kernel.storage')) {
2234
case 'array':
23-
$this->assertInstanceOf(ArrayStorage::class, $storage);
35+
$this->assertInstanceOf(ArrayTaskRepository::class, $taskRepository);
36+
$this->assertInstanceOf(ArrayTaskExecutionRepository::class, $taskExecutionRepository);
2437
break;
2538
case 'doctrine':
26-
$this->assertInstanceOf(DoctrineStorage::class, $storage);
39+
$this->assertInstanceOf(TaskRepository::class, $taskRepository);
40+
$this->assertInstanceOf(TaskExecutionRepository::class, $taskExecutionRepository);
2741
break;
2842
default:
2943
$this->fail('storage not supported');

tests/Functional/HandlerRegistryTest.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/Functional/SchedulerTest.php

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-task library.
5+
*
6+
* (c) php-task
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Functional;
13+
14+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15+
use Task\TaskBundle\Handler\TaskHandlerFactory;
16+
17+
class TaskHandlerFactoryTest extends KernelTestCase
18+
{
19+
/**
20+
* @var TaskHandlerFactory
21+
*/
22+
private $taskHandlerFactory;
23+
24+
protected function setUp()
25+
{
26+
parent::setUp();
27+
28+
$this->bootKernel();
29+
$this->taskHandlerFactory = self::$kernel->getContainer()->get('task.handler.factory');
30+
}
31+
32+
public function testRun()
33+
{
34+
$this->assertInstanceOf(\TestHandler::class, $this->taskHandlerFactory->create(\TestHandler::class));
35+
}
36+
}

tests/Unit/Command/RunCommandTest.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/Unit/Command/RunHandlerCommandTest.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

tests/Unit/Command/ScheduleTaskCommandTest.php

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)