diff --git a/.gitignore b/.gitignore
index f4686f8..c6d74bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
/.idea/
+!/Tests/App/cache/
+/Tests/App/cache/*
+!Tests/App/cache/.gitkeep
/vendor/
/composer.lock
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..12fe3b9
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+language: php
+
+php:
+ - 5.4
+ - 5.5
+ - 5.6
+ - 7.0
+
+before_script:
+ - phpunit --self-update
+ - composer self-update
+ - composer install --dev
diff --git a/Doctrine/EntityManager/JobConfigurationManager.php b/Doctrine/EntityManager/JobConfigurationManager.php
index 8cf86b2..35e1e1b 100644
--- a/Doctrine/EntityManager/JobConfigurationManager.php
+++ b/Doctrine/EntityManager/JobConfigurationManager.php
@@ -41,17 +41,23 @@ class JobConfigurationManager extends BaseJobConfigurationManager
*/
protected $class;
+ /**
+ * @var int
+ */
+ protected $resetTimeout;
+
/**
* Constructor.
*
* @param EntityManager $em
* @param string $class
*/
- public function __construct(EntityManager $em, $class)
+ public function __construct(EntityManager $em, $class, $resetTimeout)
{
$this->em = $em;
$this->repository = $em->getRepository($class);
$this->class = $em->getClassMetadata($class)->name;
+ $this->resetTimeout = $resetTimeout;
}
/**
@@ -89,9 +95,11 @@ public function findByQueueAndState($queue, $state)
/**
* {@inheritdoc}
*/
- public function findPotentialDeadJobs(\DateTime $nextStart, $queue)
+ public function findPotentialDeadJobs($queue)
{
$qb = $this->repository->createQueryBuilder('jc');
+ $nextStart = new \DateTime();
+ $nextStart->modify(sprintf('- %d seconds', $this->resetTimeout));
$qb
->select('jc')
diff --git a/Form/Subscriber/AddJobFactorySubscriber.php b/Form/Subscriber/AddJobFactorySubscriber.php
index 82208b1..db5c16c 100644
--- a/Form/Subscriber/AddJobFactorySubscriber.php
+++ b/Form/Subscriber/AddJobFactorySubscriber.php
@@ -12,8 +12,8 @@
namespace Aureja\Bundle\JobQueueBundle\Form\Subscriber;
use Aureja\Bundle\JobQueueBundle\Util\LegacyFormHelper;
+use Aureja\JobQueue\JobFactoryRegistry;
use Aureja\JobQueue\Model\JobConfigurationInterface;
-use Aureja\JobQueue\Provider\JobProviderInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@@ -28,18 +28,18 @@ class AddJobFactorySubscriber implements EventSubscriberInterface
{
/**
- * @var JobProviderInterface
+ * @var JobFactoryRegistry
*/
- private $jobProvider;
+ private $registry;
/**
* Constructor.
*
- * @param JobProviderInterface $jobProvider
+ * @param JobFactoryRegistry $registry
*/
- public function __construct(JobProviderInterface $jobProvider)
+ public function __construct(JobFactoryRegistry $registry)
{
- $this->jobProvider = $jobProvider;
+ $this->registry = $registry;
}
/**
@@ -82,7 +82,7 @@ public function addJobFactoryField(FormEvent $event)
*/
private function getFactoryNameChoices()
{
- $names = $this->jobProvider->getFactoryNames();
+ $names = $this->registry->getNames();
return array_combine($names, $names);
}
diff --git a/Resources/config/db_driver/orm.xml b/Resources/config/db_driver/orm.xml
index 7c62fd0..daf71b3 100644
--- a/Resources/config/db_driver/orm.xml
+++ b/Resources/config/db_driver/orm.xml
@@ -22,6 +22,7 @@
class="Aureja\Bundle\JobQueueBundle\Doctrine\EntityManager\JobConfigurationManager">
%aureja_job_queue.model.job_configuration.class%
+ %aureja_job_queue.reset.timeout%
diff --git a/Resources/config/doctrine/model/JobConfiguration.orm.xml b/Resources/config/doctrine/model/JobConfiguration.orm.xml
index b225c05..3f35d54 100644
--- a/Resources/config/doctrine/model/JobConfiguration.orm.xml
+++ b/Resources/config/doctrine/model/JobConfiguration.orm.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/Resources/config/form-subscribers.xml b/Resources/config/form-subscribers.xml
index 33eb5fd..079a80b 100644
--- a/Resources/config/form-subscribers.xml
+++ b/Resources/config/form-subscribers.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/Resources/config/form-types.xml b/Resources/config/form-types.xml
index 6a89d09..e6e9c6e 100644
--- a/Resources/config/form-types.xml
+++ b/Resources/config/form-types.xml
@@ -27,15 +27,6 @@
%aureja_job_queue.model.job_configuration.class%
-
-
-
-
-
- %aureja_job_queue.queues%
- %aureja_job_queue.model.job_configuration.class%
-
-
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 1e9bc47..9895be4 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -19,11 +19,11 @@
-
+
+
%aureja_job_queue.queues%
- %aureja_job_queue.reset.timeout%
@@ -35,11 +35,7 @@
-
-
-
-
-
+
diff --git a/Tests/App/AppKernel.php b/Tests/App/AppKernel.php
new file mode 100644
index 0000000..c3a637c
--- /dev/null
+++ b/Tests/App/AppKernel.php
@@ -0,0 +1,30 @@
+load(__DIR__ . '/config.yml');
+ }
+}
diff --git a/Tests/App/Entity/JobConfiguration.php b/Tests/App/Entity/JobConfiguration.php
new file mode 100644
index 0000000..bae8e9f
--- /dev/null
+++ b/Tests/App/Entity/JobConfiguration.php
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/App/Resources/config/doctrine/JobReport.orm.xml b/Tests/App/Resources/config/doctrine/JobReport.orm.xml
new file mode 100644
index 0000000..ecdfe49
--- /dev/null
+++ b/Tests/App/Resources/config/doctrine/JobReport.orm.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/App/bootstrap.php b/Tests/App/bootstrap.php
new file mode 100644
index 0000000..5061c3d
--- /dev/null
+++ b/Tests/App/bootstrap.php
@@ -0,0 +1,8 @@
+initClient();
+
+ $this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
+
+ $this->createSchema();
+ }
+
+ public function testRun()
+ {
+
+ }
+
+ private function createSchema()
+ {
+ $schemaTool = new SchemaTool($this->em);
+ $schemaTool->createSchema(
+ [
+ $this->em->getClassMetadata(JobConfiguration::class),
+ $this->em->getClassMetadata(JobReport::class),
+ ]
+ );
+
+ }
+}
diff --git a/composer.json b/composer.json
index ff83f8f..de6cb51 100644
--- a/composer.json
+++ b/composer.json
@@ -11,11 +11,14 @@
"require": {
"php": ">=5.4",
- "aureja/job-queue": "0.1.*",
- "symfony/framework-bundle" : ">=2.7|~3.0"
+ "aureja/job-queue": "0.2.*@dev",
+ "symfony/symfony" : ">=2.7|~3.0",
+ "doctrine/doctrine-bundle": "~1.4"
},
"require-dev": {
- "phpunit/phpunit": "~4.2"
+ "doctrine/orm": "~2.4,>=2.4.5",
+ "phpunit/phpunit": "~4.2",
+ "aureja/test-framework-bundle": "~0.1"
},
"suggest": {
"silvestra/paginator-bundle": "For using the job reports pagination."
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..efce75e
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Tests/Functional
+
+
+
+
+
+ .
+
+ Tests/
+ vendor/
+
+
+
+
\ No newline at end of file