Skip to content

Commit a6e8a02

Browse files
author
Jacob Bare
authored
Merge pull request #3 from zarathustra323/slinsights
Minor bug fixes/cleanup and initial testing
2 parents a938d72 + 50df52f commit a6e8a02

File tree

8 files changed

+65
-7
lines changed

8 files changed

+65
-7
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646

4747
# Backup entities generated with doctrine:generate:entities command
4848
*/Entity/*~
49-
.DS_Store
49+
/composer.lock

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: php
2+
php:
3+
- '5.4'
4+
- '5.6'
5+
install:
6+
- composer install --no-interaction

DependencyInjection/As3PostProcessExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
use Symfony\Component\Config\FileLocator;
77
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
88
use Symfony\Component\DependencyInjection\Loader;
9-
use Symfony\Component\DependencyInjection\Definition;
10-
use Symfony\Component\DependencyInjection\Reference;
119

1210
/**
1311
* This is the class that loads and manages your bundle configuration
@@ -22,7 +20,7 @@ class As3PostProcessExtension extends Extension
2220
public function load(array $configs, ContainerBuilder $container)
2321
{
2422
$configuration = new Configuration();
25-
$config = $this->processConfiguration($configuration, $configs);
23+
$this->processConfiguration($configuration, $configs);
2624

2725
// Load bundle services
2826
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface
1818
public function getConfigTreeBuilder()
1919
{
2020
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('as3_post_process');
21+
$treeBuilder->root('as3_post_process');
2222
return $treeBuilder;
2323
}
2424
}

Task/TaskManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function addTask(TaskInterface $task, $priority = 0)
6363
'object' => $task,
6464
'priority' => (Integer) $priority,
6565
];
66-
$this->tasks[get_class($task)] = $prioritized;
66+
$this->tasks[] = $prioritized;
6767

6868
$sortFunc = function ($a, $b) {
6969
return $a['priority'] > $b['priority'] ? -1 : 1;

Tests/TaskManagerTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace As3\Bundle\PostProcessBundle\Tests;
4+
5+
use As3\Bundle\PostProcessBundle\Task\TaskManager;
6+
7+
class TaskManagerTest extends \PHPUnit_Framework_TestCase
8+
{
9+
private $manager;
10+
11+
protected function setUp()
12+
{
13+
$this->manager = new TaskManager();
14+
}
15+
16+
public function testTaskPriority()
17+
{
18+
$task1 = new TestTask('1');
19+
$task2 = new TestTask('2');
20+
$task3 = new TestTask('3');
21+
22+
$this->manager->addTask($task1);
23+
$this->manager->addTask($task2, 5);
24+
$this->manager->addTask($task3, 1);
25+
26+
$tasks = $this->manager->getTasks();
27+
$this->assertEquals(3, count($tasks));
28+
$this->assertEquals('2', $tasks[0]->getKey(), 'Task priority order is incorrect.');
29+
$this->assertEquals('3', $tasks[1]->getKey(), 'Task priority order is incorrect.');
30+
}
31+
}

Tests/TestTask.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace As3\Bundle\PostProcessBundle\Tests;
4+
5+
use As3\Bundle\PostProcessBundle\Task\TaskInterface;
6+
7+
class TestTask implements TaskInterface
8+
{
9+
private $key;
10+
11+
public function __construct($key)
12+
{
13+
$this->key = $key;
14+
}
15+
16+
public function getKey()
17+
{
18+
return $this->key;
19+
}
20+
21+
public function run()
22+
{
23+
}
24+
}

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "as3/post-process-bundle",
33
"type": "symfony-bundle",
44
"license": "MIT",
5-
"type": "library",
65
"description": "Provides centralized support for executing callable code before Symfony framework termination.",
76
"authors": [
87
{

0 commit comments

Comments
 (0)