Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from theofidry/history
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Apr 23, 2016
2 parents 54255e1 + 565b2a3 commit 0ec5fa6
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 10 deletions.
79 changes: 79 additions & 0 deletions coverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1461434799">
<project timestamp="1461434799">
<package name="Fidry\PsyshBundle\Command">
<file name="/Users/Theo/Sites/GitHub/PsyshBundle/src/Command/PsyshCommand.php">
<class name="PsyshCommand" namespace="Fidry\PsyshBundle\Command">
<metrics complexity="3" methods="3" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="8" elements="11" coveredelements="11"/>
</class>
<line num="33" type="method" name="__construct" visibility="public" complexity="1" crap="1" count="4"/>
<line num="35" type="stmt" count="4"/>
<line num="37" type="stmt" count="4"/>
<line num="38" type="stmt" count="4"/>
<line num="43" type="method" name="configure" visibility="protected" complexity="1" crap="1" count="4"/>
<line num="46" type="stmt" count="4"/>
<line num="47" type="stmt" count="4"/>
<line num="48" type="stmt" count="4"/>
<line num="53" type="method" name="execute" visibility="protected" complexity="1" crap="1" count="1"/>
<line num="55" type="stmt" count="1"/>
<line num="56" type="stmt" count="1"/>
<metrics loc="57" ncloc="33" classes="1" methods="3" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="8" elements="11" coveredelements="11"/>
</file>
</package>
<package name="Fidry\PsyshBundle\DependencyInjection">
<file name="/Users/Theo/Sites/GitHub/PsyshBundle/src/DependencyInjection/Psysh.php">
<class name="Psysh" namespace="Fidry\PsyshBundle\DependencyInjection">
<metrics complexity="3" methods="3" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="7" coveredstatements="2" elements="10" coveredelements="3"/>
</class>
<line num="26" type="method" name="init" visibility="public" complexity="1" crap="1" count="2"/>
<line num="28" type="stmt" count="2"/>
<line num="29" type="stmt" count="2"/>
<line num="31" type="method" name="debug" visibility="public" complexity="1" crap="2" count="0"/>
<line num="33" type="stmt" count="0"/>
<line num="35" type="stmt" count="0"/>
<line num="36" type="stmt" count="0"/>
<line num="38" type="stmt" count="0"/>
<line num="40" type="method" name="getInstance" visibility="public" complexity="1" crap="2" count="0"/>
<line num="42" type="stmt" count="0"/>
<metrics loc="44" ncloc="30" classes="1" methods="3" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="7" coveredstatements="2" elements="10" coveredelements="3"/>
</file>
<file name="/Users/Theo/Sites/GitHub/PsyshBundle/src/DependencyInjection/PsyshExtension.php">
<class name="PsyshExtension" namespace="Fidry\PsyshBundle\DependencyInjection">
<metrics complexity="2" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="6" elements="9" coveredelements="6"/>
</class>
<line num="31" type="method" name="load" visibility="public" complexity="2" crap="2.06" count="1"/>
<line num="33" type="stmt" count="1"/>
<line num="34" type="stmt" count="1"/>
<line num="36" type="stmt" count="1"/>
<line num="37" type="stmt" count="1"/>
<line num="38" type="stmt" count="1"/>
<line num="39" type="stmt" count="0"/>
<line num="40" type="stmt" count="0"/>
<line num="42" type="stmt" count="1"/>
<metrics loc="43" ncloc="25" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="6" elements="9" coveredelements="6"/>
</file>
</package>
<package name="Fidry\PsyshBundle">
<file name="/Users/Theo/Sites/GitHub/PsyshBundle/src/PsyshBundle.php">
<class name="PsyshBundle" namespace="Fidry\PsyshBundle">
<metrics complexity="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="4" coveredstatements="4" elements="5" coveredelements="5"/>
</class>
<line num="24" type="method" name="boot" visibility="public" complexity="1" crap="1" count="2"/>
<line num="26" type="stmt" count="2"/>
<line num="29" type="stmt" count="2"/>
<line num="30" type="stmt" count="2"/>
<line num="31" type="stmt" count="2"/>
<metrics loc="33" ncloc="20" classes="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="4" coveredstatements="4" elements="5" coveredelements="5"/>
</file>
</package>
<file name="/Users/Theo/Sites/GitHub/PsyshBundle/src/Support/psysh.php">
<line num="3" type="stmt" count="0"/>
<line num="5" type="stmt" count="0"/>
<line num="6" type="stmt" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<metrics loc="8" ncloc="8" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="0" elements="5" coveredelements="0"/>
</file>
<metrics files="5" loc="185" ncloc="116" classes="4" methods="8" coveredmethods="5" conditionals="0" coveredconditionals="0" statements="32" coveredstatements="20" elements="40" coveredelements="25"/>
</project>
</coverage>
2 changes: 1 addition & 1 deletion src/Command/PsyshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->shell->debug($this->shell->getScopeVariables());
$this->shell->run();
}
}
6 changes: 5 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="psysh.config" class="Psy\Configuration" />
<service id="psysh.config" class="Psy\Configuration">
<call method="setHistoryFile">
<argument>%kernel.cache_dir%/psysh_history</argument>
</call>
</service>

<service id="psysh.shell" class="Psy\Shell">
<argument type="service" id="psysh.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
namespace Fidry\PsyshBundle\Tests\Command;

use Fidry\PsyshBundle\Command\PsyshCommand;
use Fidry\PsyshBundle\DependencyInjection\Psysh;
use Psy\Shell;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @coversDefaultClass Fidry\PsyshBundle\Command\PsyshCommand
*
* @author Théo FIDRY <[email protected]>
*/
class PsyshCommandTest extends KernelTestCase
class PsyshCommandIntegrationTest extends KernelTestCase
{
/**
* @var Shell
Expand Down Expand Up @@ -56,9 +50,13 @@ public function testScopeVariables()
'kernel',
'parameters',
'_',
'self',
],
array_keys($this->shell->getScopeVariables()),
'Expected shell service to have scope variables'
'Expected shell service to have scope variables',
0.0,
10,
true
);
}

Expand Down
62 changes: 62 additions & 0 deletions tests/Command/PsyshCommandUnitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
* This file is part of the PsyshBundle package.
*
* (c) Théo FIDRY <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Fidry\PsyshBundle\Tests\Command;

use Fidry\PsyshBundle\Command\PsyshCommand;
use Prophecy\Argument;
use Psy\Shell;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* @coversDefaultClass Fidry\PsyshBundle\Command\PsyshCommand
*
* @author Théo FIDRY <[email protected]>
*/
class PsyshCommandUnitTest extends \PHPUnit_Framework_TestCase
{
public function testIsASymfonyCommand()
{
$this->assertTrue(is_subclass_of('Fidry\PsyshBundle\Command\PsyshCommand', 'Symfony\Component\Console\Command\Command'));
}

public function testConfiguration()
{
$shellProphecy = $this->prophesize('Psy\Shell');
$shellProphecy->run()->shouldNotBeCalled();
/* @var Shell $shell */
$shell = $shellProphecy->reveal();

$command = new PsyshCommand($shell);
$this->assertEquals('psysh', $command->getName());
$this->assertEquals('Start PsySH for Symfony', $command->getDescription());
}

public function testExecute()
{
$shellProphecy = $this->prophesize('Psy\Shell');
$shellProphecy->run()->shouldBeCalled();
/* @var Shell $shell */
$shell = $shellProphecy->reveal();

/* @var InputInterface $input */
$input = $this->prophesize('Symfony\Component\Console\Input\InputInterface')->reveal();
/* @var OutputInterface $output */
$output = $this->prophesize('Symfony\Component\Console\Output\OutputInterface')->reveal();

$command = new PsyshCommand($shell);
$command->run($input, $output);

$shellProphecy->run()->shouldHaveBeenCalledTimes(1);
}
}

0 comments on commit 0ec5fa6

Please sign in to comment.