Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from ricardclau/add_tests
add tests and removed someuseless use and bundle construct
- Loading branch information
Showing
6 changed files
with
134 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace RaulFraile\Bundle\LadybugBundle\Tests\DataCollector; | ||
|
||
use Ladybug\Dumper; | ||
use Mockery as m; | ||
use RaulFraile\Bundle\LadybugBundle\DataCollector\LadybugDataCollector; | ||
|
||
class LadybugDataCollectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Ladybug\Dumper | ||
*/ | ||
private $dumper; | ||
|
||
protected function setUp() | ||
{ | ||
$this->dumper = m::mock('Ladybug\Dumper'); | ||
$this->dumper->shouldReceive('setFormat')->withArgs(array('html')); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->dumper = null; | ||
} | ||
|
||
public function testLogDataWorksAsExpected() | ||
{ | ||
$this->dumper->shouldReceive('dump')->once()->withArgs(array('#foo#', '#bar#'))->andReturn('#html#'); | ||
$this->dumper->shouldReceive('dump')->once()->withArgs(array('#foo2#', '#bar2#'))->andReturn('#html2#'); | ||
|
||
$ladybugDataCollector = new LadybugDataCollector($this->dumper); | ||
$ladybugDataCollector->log('#foo#', '#bar#'); | ||
$ladybugDataCollector->log('#foo2#', '#bar2#'); | ||
$collectedVars = $ladybugDataCollector->getVars(); | ||
|
||
$this->assertCount(2, $collectedVars); | ||
|
||
foreach ($collectedVars as $collected) { | ||
$this->assertArrayHasKey('file', $collected); | ||
$this->assertArrayHasKey('line', $collected); | ||
$this->assertArrayHasKey('content', $collected); | ||
} | ||
|
||
$this->assertEquals('#html#', $collectedVars[0]['content']); | ||
$this->assertEquals('#html2#', $collectedVars[1]['content']); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Tests/DependencyInjection/RaulFraileLadybugExtensionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace RaulFraile\Bundle\LadybugBundle\Tests\DependencyInjection; | ||
|
||
use RaulFraile\Bundle\LadybugBundle\DependencyInjection\RaulFraileLadybugExtension; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
class RaulFraileLadybugExtensionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \RaulFraile\Bundle\LadybugBundle\DependencyInjection\RaulFraileLadybugExtension | ||
*/ | ||
private $extension; | ||
|
||
/** | ||
* @var \Symfony\Component\DependencyInjection\ContainerBuilder | ||
*/ | ||
private $container; | ||
|
||
protected function setUp() | ||
{ | ||
$this->extension = new RaulFraileLadybugExtension(); | ||
$this->container = new ContainerBuilder(); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->extension = null; | ||
$this->container = null; | ||
} | ||
|
||
public function testEmptyConfigUsesDefaultValuesAndServicesAreCreated() | ||
{ | ||
$this->extension->load(array(), $this->container); | ||
|
||
$this->assertTrue($this->container->has('data_collector.ladybug_data_collector')); | ||
$this->assertTrue($this->container->has('ladybug.twig.extension')); | ||
$this->assertTrue($this->container->has('ladybug.dumper')); | ||
$this->assertTrue($this->container->has('ladybug.event_listener.ladybug_config_listener')); | ||
|
||
$bundleOptions = $this->container->getParameterBag('raul_fraile_ladybug')->get('ladybug.options'); | ||
$this->assertEquals('modern', $bundleOptions['theme']); | ||
$this->assertFalse($bundleOptions['expanded']); | ||
$this->assertFalse($bundleOptions['silenced']); | ||
$this->assertEquals(9, $bundleOptions['array_max_nesting_level']); | ||
$this->assertEquals(3, $bundleOptions['object_max_nesting_level']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace RaulFraile\Bundle\LadybugBundle\Tests\Twig\Extension; | ||
|
||
use Ladybug\Dumper; | ||
use Mockery as m; | ||
use RaulFraile\Bundle\LadybugBundle\Twig\Extension\LadybugExtension; | ||
|
||
class LadybugExtensionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Ladybug\Dumper | ||
*/ | ||
private $dumper; | ||
|
||
protected function setUp() | ||
{ | ||
$this->dumper = m::mock('Ladybug\Dumper'); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->dumper = null; | ||
} | ||
|
||
public function testLadybugDumpWorksAsExpectedInsideTwigExtension() | ||
{ | ||
$this->dumper->shouldReceive('dump')->once()->withArgs(array('#foo#', '#bar#'))->andReturn('#html#'); | ||
$ladybugExtension = new LadybugExtension($this->dumper); | ||
|
||
$this->assertEquals('#html#', $ladybugExtension->ladybug_dump('#foo#', '#bar#')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters