Skip to content

Minor bug fixes/cleanup and initial testing #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 1, 2016
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@

# Backup entities generated with doctrine:generate:entities command
*/Entity/*~
.DS_Store
/composer.lock
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: php
php:
- '5.4'
- '5.6'
install:
- composer install --no-interaction
4 changes: 1 addition & 3 deletions DependencyInjection/As3PostProcessExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

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

// Load bundle services
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('as3_post_process');
$treeBuilder->root('as3_post_process');
return $treeBuilder;
}
}
2 changes: 1 addition & 1 deletion Task/TaskManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function addTask(TaskInterface $task, $priority = 0)
'object' => $task,
'priority' => (Integer) $priority,
];
$this->tasks[get_class($task)] = $prioritized;
$this->tasks[] = $prioritized;

$sortFunc = function ($a, $b) {
return $a['priority'] > $b['priority'] ? -1 : 1;
Expand Down
31 changes: 31 additions & 0 deletions Tests/TaskManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace As3\Bundle\PostProcessBundle\Tests;

use As3\Bundle\PostProcessBundle\Task\TaskManager;

class TaskManagerTest extends \PHPUnit_Framework_TestCase
{
private $manager;

protected function setUp()
{
$this->manager = new TaskManager();
}

public function testTaskPriority()
{
$task1 = new TestTask('1');
$task2 = new TestTask('2');
$task3 = new TestTask('3');

$this->manager->addTask($task1);
$this->manager->addTask($task2, 5);
$this->manager->addTask($task3, 1);

$tasks = $this->manager->getTasks();
$this->assertEquals(3, count($tasks));
$this->assertEquals('2', $tasks[0]->getKey(), 'Task priority order is incorrect.');
$this->assertEquals('3', $tasks[1]->getKey(), 'Task priority order is incorrect.');
}
}
24 changes: 24 additions & 0 deletions Tests/TestTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace As3\Bundle\PostProcessBundle\Tests;

use As3\Bundle\PostProcessBundle\Task\TaskInterface;

class TestTask implements TaskInterface
{
private $key;

public function __construct($key)
{
$this->key = $key;
}

public function getKey()
{
return $this->key;
}

public function run()
{
}
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "as3/post-process-bundle",
"type": "symfony-bundle",
"license": "MIT",
"type": "library",
"description": "Provides centralized support for executing callable code before Symfony framework termination.",
"authors": [
{
Expand Down