Skip to content

Commit c2e4879

Browse files
init testcases
1 parent d83d85a commit c2e4879

File tree

11 files changed

+128
-4
lines changed

11 files changed

+128
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ composer.phar
44

55
*.iml
66
/.idea
7+
8+
tests/app/cache
9+
tests/app/logs

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tools:
2+
external_code_coverage: true

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
3+
php:
4+
- 5.5
5+
- 5.6
6+
- 7.0
7+
- hhvm
8+
9+
env:
10+
- STORAGE=array
11+
12+
install:
13+
- composer self-update
14+
- composer update
15+
- wget https://scrutinizer-ci.com/ocular.phar
16+
17+
script:
18+
- phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
19+
20+
after_script:
21+
- php ocular.phar code-coverage:upload --access-token="230ec5e01daf5bb3e46ea304fb20348b52d80de73463ec08ee9c96fcd1349e35" --format=php-clover coverage.clover

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# TaskBundle
2+
3+
[![Build Status](https://travis-ci.org/php-task/TaskBundle.svg?branch=master)](https://travis-ci.org/php-task/PHPTaskBundle?branch=master)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/php-task/TaskBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/php-task/TaskBundle/?branch=master)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/php-task/TaskBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-task/TaskBundle/?branch=master)
6+
27
Symfony integration for PHPTask library.

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^5.5",
13+
"php": "^5.5 || ^7.0",
1414
"php-task/php-task": "1.0.x-dev@dev",
1515
"symfony/http-kernel": "^2.6",
1616
"symfony/dependency-injection": "^2.6",
1717
"symfony/config": "^2.6",
1818
"symfony/console": "^2.6"
1919
},
20+
"require-dev": {
21+
"phpunit/phpunit": "^4.8",
22+
"symfony/framework-bundle": "^2.6",
23+
"symfony/finder": "^2.6"
24+
},
2025
"autoload": {
2126
"psr-4": {
2227
"Task\\TaskBundle\\": "src"

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php">
8+
<php>
9+
<ini name="error_reporting" value="-1" />
10+
<server name="KERNEL_DIR" value="tests/app" />
11+
</php>
12+
13+
<testsuites>
14+
<testsuite name="php-task Library Test Suite">
15+
<directory>./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<filter>
20+
<whitelist>
21+
<directory>./</directory>
22+
<exclude>
23+
<directory>./vendor</directory>
24+
<directory>./tests</directory>
25+
</exclude>
26+
</whitelist>
27+
</filter>
28+
</phpunit>

src/DependencyInjection/TaskExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public function load(array $configs, ContainerBuilder $container)
2323
$config = $this->processConfiguration($configuration, $configs);
2424

2525
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
26-
$loader->load(sprintf('storage/%s'), $config['storage']);
27-
$loader->load('services.xml');
26+
$loader->load(sprintf('storage/%s.xml', $config['storage']));
27+
$loader->load('scheduler.xml');
28+
$loader->load('command.xml');
2829
}
2930
}

src/Resources/config/command.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55
<services>
66
<service id="task.command.run" class="Task\TaskBundle\Command\RunCommand">
7-
<argument type="service" id="task.runner"/>
7+
<argument type="service" id="task.scheduler"/>
88

99
<tag name="console.command"/>
1010
</service>

tests/Functional/SchedulerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Functional;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6+
use Task\SchedulerInterface;
7+
use Task\Storage\ArrayStorage;
8+
9+
class SchedulerTest extends KernelTestCase
10+
{
11+
public function testBootstrap()
12+
{
13+
$this->bootKernel();
14+
15+
$scheduler = self::$kernel->getContainer()->get('task.scheduler');
16+
$storage = self::$kernel->getContainer()->get('task.storage');
17+
18+
$this->assertInstanceOf(SchedulerInterface::class, $scheduler);
19+
20+
switch (getenv(\TestKernel::STORAGE_VAR_NAME)) {
21+
case 'array':
22+
$this->assertInstanceOf(ArrayStorage::class, $storage);
23+
break;
24+
default:
25+
$this->fail('storage not supported');
26+
break;
27+
}
28+
}
29+
}

tests/app/TestKernel.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Symfony\Component\Config\Loader\LoaderInterface;
4+
use Symfony\Component\HttpKernel\Kernel;
5+
use Task\TaskBundle\TaskBundle;
6+
7+
class TestKernel extends Kernel
8+
{
9+
const STORAGE_VAR_NAME = 'STORAGE';
10+
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
public function registerBundles()
15+
{
16+
return [
17+
new TaskBundle(),
18+
];
19+
}
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function registerContainerConfiguration(LoaderInterface $loader)
25+
{
26+
$loader->load(sprintf('%s/config/config.%s.yml', __DIR__, getenv(self::STORAGE_VAR_NAME)));
27+
}
28+
}

0 commit comments

Comments
 (0)