Skip to content

Commit

Permalink
Merge pull request #20 from Saloodo/Adding-sf4-support-and-testing
Browse files Browse the repository at this point in the history
Adding sf4 support and testing
  • Loading branch information
RamyHakam authored Jan 21, 2021
2 parents f23d4dd + fc0b41b commit 6c76210
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 9 deletions.
26 changes: 18 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
language: php
sudo: true
php
- 7.1
- 7.2

language: bash
matrix:
include:
- php: 7.1
env: SYMFONY_VERSION='3.4.*'
- php: 7.2
env: DEPENDENCIES='dev' SYMFONY_VERSION='3.4.*@dev'
- php: 7.2
env: SYMFONY_VERSION='4.4.*@dev'

branches:
only:
- master
- develop
before_install:
- composer self-update
- if [ "$DEPENDENCIES" == "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer --no-update require symfony/symfony:${SYMFONY_VERSION}; fi;

script:
- echo "something"
- ls -al ~/.ssh/
install: composer update $COMPOSER_FLAGS

script: vendor/bin/phpunit
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
"symfony/framework-bundle": "~3.0|~4.0",
"dragonmantank/cron-expression": "^2.0",
"symfony/process": "~3.0|~4.0",
"symfony/lock": "~3.0|~4.0"
"symfony/lock": "~3.0|~4.0",
"symfony/yaml": "~3.0|~4.0"
},
"autoload-dev": {
"psr-4": {
"Saloodo\\Scheduler\\Tests\\":"tests/"
}
},
"require-dev": {
"phpunit/phpunit": "^7.0",
Expand Down
73 changes: 73 additions & 0 deletions tests/Functional/ServiceWiringTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php


namespace Saloodo\Scheduler\Tests\Functional;


use PHPUnit\Framework\TestCase;
use Saloodo\Scheduler\Jobs\Mutex\JobLocker;
use Saloodo\Scheduler\Jobs\Mutex\JobSymfonyLocker;
use Saloodo\Scheduler\Jobs\Mutex\SchedulerLocker;
use Saloodo\Scheduler\Jobs\Mutex\SchedulerSymfonyLocker;
use Saloodo\Scheduler\Jobs\Scheduler;
use Saloodo\Scheduler\Tests\SchedulerBundleKernel;
use Symfony\Component\DependencyInjection\ContainerInterface;

class ServiceWiringTest extends TestCase
{
/**
* @var ContainerInterface
*/
private $container;

public function testSchedulerLockerServiceWiring(): void
{
/** @var SchedulerLocker $schedulerLockerService */
$schedulerLockerService = $this->container->get(SchedulerLocker::class);

self::assertInstanceOf(SchedulerLocker::class, $schedulerLockerService);
}

public function testSchedulerSymfonyLockerWiring(): void
{
/** @var SchedulerSymfonyLocker $schedulerSymfonyLockerService */
$schedulerSymfonyLockerService = $this->container->get(SchedulerSymfonyLocker::class);

self::assertInstanceOf(SchedulerSymfonyLocker::class, $schedulerSymfonyLockerService);
}

public function testJobLockerWiring(): void
{
/** @var JobLocker $jobLocker */
$jobLocker = $this->container->get(JobLocker::class);

self::assertInstanceOf(JobLocker::class, $jobLocker);
}

public function testJobSymfonyLockerWiring(): void
{
/** @var JobLocker $jobSymfonyLocker */
$jobSymfonyLocker = $this->container->get(JobSymfonyLocker::class);

self::assertInstanceOf(JobSymfonyLocker::class, $jobSymfonyLocker);
}

public function testSchedulerWiring(): void
{
/** @var Scheduler $scheduler */
$scheduler = $this->container->get(Scheduler::class);

self::assertInstanceOf(Scheduler::class, $scheduler);
}

protected function setUp(): void
{
$config = [
'cache_driver' => 'test_cache_driver',
'cache_store' => 'test_cache_store'
];
$kernel = new SchedulerBundleKernel($config);
$kernel->boot();
$this->container = $kernel->getContainer();
}
}
42 changes: 42 additions & 0 deletions tests/SchedulerBundleKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php


namespace Saloodo\Scheduler\Tests;


use Saloodo\Scheduler\SchedulerBundle;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Lock\Store\FlockStore;

class SchedulerBundleKernel extends Kernel
{

private $saloodoSchedulerConfig;

public function __construct(array $config = [])
{
$this->saloodoSchedulerConfig = $config;
parent::__construct('test', true);
}

public function registerBundles()
{
return [
new SchedulerBundle()
];
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$container->register('test_cache_driver', FilesystemAdapter::class);
$container->register('test_cache_store', FlockStore::class);
$container->register('event_dispatcher', EventDispatcher::class);
$container->loadFromExtension('scheduler', $this->saloodoSchedulerConfig);
});
}
}

0 comments on commit 6c76210

Please sign in to comment.