Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/.idea/
!/Tests/App/cache/
/Tests/App/cache/*
!Tests/App/cache/.gitkeep
/vendor/
/composer.lock
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions Doctrine/EntityManager/JobConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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')
Expand Down
14 changes: 7 additions & 7 deletions Form/Subscriber/AddJobFactorySubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions Resources/config/db_driver/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class="Aureja\Bundle\JobQueueBundle\Doctrine\EntityManager\JobConfigurationManager">
<argument type="service" id="doctrine.orm.entity_manager"/>
<argument>%aureja_job_queue.model.job_configuration.class%</argument>
<argument>%aureja_job_queue.reset.timeout%</argument>
</service>

<!--Job report default manager-->
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/doctrine/model/JobConfiguration.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<field name="autoRestorable" column="auto_restorable" type="boolean" nullable="false" />

<field name="factory" column="factory" type="string" length="255" nullable="false" />
<field name="factoryName" column="factory_name" type="string" length="255" nullable="false" />

<field name="name" column="name" type="string" length="255" nullable="false" unique="true" />

Expand Down
2 changes: 1 addition & 1 deletion Resources/config/form-subscribers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<services>

<service id="aureja_job_queue.form_subscriber.add_job_factory" class="Aureja\Bundle\JobQueueBundle\Form\Subscriber\AddJobFactorySubscriber">
<argument type="service" id="aureja_job_queue.provider.job" />
<argument type="service" id="aureja_job_queue.registry.job_factory" />
</service>

<service id="aureja_job_queue.form_subscriber.add_job_parameters" class="Aureja\Bundle\JobQueueBundle\Form\Subscriber\AddJobParametersSubscriber" />
Expand Down
9 changes: 0 additions & 9 deletions Resources/config/form-types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@
<argument>%aureja_job_queue.model.job_configuration.class%</argument>
</service>

<!--Job pre configuration form type-->
<service id="aureja_job_queue.form_type.job_pre_configuration" class="Aureja\Bundle\JobQueueBundle\Form\Type\JobPreConfigurationType">
<tag name="form.type" alias="aureja_job_pre_configuration" />

<argument type="service" id="aureja_job_queue.provider.job" />
<argument>%aureja_job_queue.queues%</argument>
<argument>%aureja_job_queue.model.job_configuration.class%</argument>
</service>

<!--Php job factory form type-->
<service id="aureja_job_queue.form_type.php_job_factory" class="Aureja\Bundle\JobQueueBundle\Form\Type\PhpJobFactoryType">
<tag name="form.type" alias="aureja_php_job_factory" />
Expand Down
10 changes: 3 additions & 7 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

<service id="aureja_job_queue" class="Aureja\JobQueue\JobQueue">
<argument type="service" id="aureja_job_queue.manager.job_configuration" />
<argument type="service" id="aureja_job_queue.provider.job" />
<argument type="service" id="event_dispatcher" />
<argument type="service" id="aureja_job_queue.registry.job_factory" />
<argument type="service" id="aureja_job_queue.manager.job_report" />
<argument type="service" id="aureja_job_queue.manager.job_restore" />
<argument>%aureja_job_queue.queues%</argument>
<argument>%aureja_job_queue.reset.timeout%</argument>
</service>

<service id="aureja_job_queue.builder.symfony_command" class="Aureja\JobQueue\Extension\Symfony\Command\CommandBuilder">
Expand All @@ -35,11 +35,7 @@
<argument type="service" id="aureja_job_queue.manager.job_report" />
</service>

<service id="aureja_job_queue.provider.job" class="Aureja\JobQueue\Provider\JobProvider">
<argument type="service" id="aureja_job_queue.registry.job_factory" />
</service>

<service id="aureja_job_queue.registry.job_factory" class="Aureja\JobQueue\Register\JobFactoryRegistry" />
<service id="aureja_job_queue.registry.job_factory" class="Aureja\JobQueue\JobFactoryRegistry" />

<service id="aureja_job_queue.validator.unique_job_configuration" class="Aureja\Bundle\JobQueueBundle\Validator\Constraints\UniqueJobConfigurationValidator">
<tag name="validator.constraint_validator" alias="aureja_job_queue.unique_job_configuration"/>
Expand Down
30 changes: 30 additions & 0 deletions Tests/App/AppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
/**
* {@inheritdoc}
*/
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Aureja\Bundle\TestFrameworkBundle\AurejaTestFrameworkBundle(),
new Aureja\Bundle\JobQueueBundle\AurejaJobQueueBundle(),
];

return $bundles;
}
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config.yml');
}
}
10 changes: 10 additions & 0 deletions Tests/App/Entity/JobConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aureja\Bundle\JobQueueBundle\Tests\App\Entity;

use Aureja\JobQueue\Model\JobConfiguration as BaseJobConfiguration;

class JobConfiguration extends BaseJobConfiguration
{

}
10 changes: 10 additions & 0 deletions Tests/App/Entity/JobReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aureja\Bundle\JobQueueBundle\Tests\App\Entity;

use Aureja\JobQueue\Model\JobReport as BaseJobReport;

class JobReport extends BaseJobReport
{

}
16 changes: 16 additions & 0 deletions Tests/App/Resources/config/doctrine/JobConfiguration.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Aureja\Bundle\JobQueueBundle\Tests\App\Entity\JobConfiguration" table="aureja_job_configuration">

<id name="id" type="integer">
<generator strategy="AUTO" />
</id>

</entity>

</doctrine-mapping>
16 changes: 16 additions & 0 deletions Tests/App/Resources/config/doctrine/JobReport.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

<entity name="Aureja\Bundle\JobQueueBundle\Tests\App\Entity\JobReport" table="aureja_job_report">

<id name="id" type="integer">
<generator strategy="AUTO" />
</id>

</entity>

</doctrine-mapping>
8 changes: 8 additions & 0 deletions Tests/App/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = require __DIR__.'/../../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

return $loader;
Empty file added Tests/App/cache/.gitkeep
Empty file.
47 changes: 47 additions & 0 deletions Tests/App/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
framework:
secret: secret
test: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
storage_id: session.storage.filesystem
# https://groups.google.com/forum/#!topic/symfony2/IB-CpMgo5o0
name: MOCKSESSID
profiler:
collect: false
router:
resource: "%kernel.root_dir%/routing.yml"
strict_requirements: ~
templating:
engines: [twig]

twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"

doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test.db"
charset: UTF8
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
AurejaJobQueueBundle:
type: xml
dir: "%kernel.root_dir%/../App/Resources/config/doctrine"
prefix: "Aureja\\Bundle\\JobQueueBundle\\Tests\\App\\Entity"

# Aureja job queue configuration
aureja_job_queue:
db_driver: orm
class:
model:
job_configuration: "Aureja\\Bundle\\JobQueueBundle\\Tests\\App\\Entity\\JobConfiguration"
job_report: "Aureja\\Bundle\\JobQueueBundle\\Tests\\App\\Entity\\JobReport"
queues:
- default
- import
Empty file added Tests/App/routing.yml
Empty file.
43 changes: 43 additions & 0 deletions Tests/Functional/JobQueueTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Aureja\Bundle\JobQueueBundle\Tests\Functional;

use Aureja\Bundle\JobQueueBundle\Tests\App\Entity\JobConfiguration;
use Aureja\Bundle\JobQueueBundle\Tests\App\Entity\JobReport;
use Aureja\Bundle\TestFrameworkBundle\Test\WebTestCase;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaTool;

class JobQueueTest extends WebTestCase
{
/**
* @var EntityManagerInterface
*/
private $em;

protected function setUp()
{
$this->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),
]
);

}
}
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
Loading