From f45bfefa6f8706f1c7b811c9a83548e8cda71c90 Mon Sep 17 00:00:00 2001 From: prolic Date: Sat, 18 Jun 2016 17:00:59 +0800 Subject: [PATCH] add first test case for new module --- .php_cs | 39 +++++++++++++++ composer.json | 9 +++- phpunit.xml.dist | 2 +- .../Console/Input/RequestInput.php | 0 .../Console/Output/PropertyOutput.php | 0 .../Container/CliFactory.php | 0 src/{HumusAmqpModule => }/Module.php | 0 tests/Container/CliFactoryTest.php | 48 +++++++++++++++++++ 8 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 .php_cs rename src/{HumusAmqpModule => }/Console/Input/RequestInput.php (100%) rename src/{HumusAmqpModule => }/Console/Output/PropertyOutput.php (100%) rename src/{HumusAmqpModule => }/Container/CliFactory.php (100%) rename src/{HumusAmqpModule => }/Module.php (100%) create mode 100644 tests/Container/CliFactoryTest.php diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..4b7b398 --- /dev/null +++ b/.php_cs @@ -0,0 +1,39 @@ +in('bin') + ->in('src') + ->in('tests'); +$config = Symfony\CS\Config\Config::create(); +$config->level(null); +$config->fixers( + array( + 'braces', + 'duplicate_semicolon', + 'elseif', + 'empty_return', + 'encoding', + 'eof_ending', + 'function_call_space', + 'function_declaration', + 'indentation', + 'join_function', + 'line_after_namespace', + 'linefeed', + 'lowercase_keywords', + 'parenthesis', + 'multiple_use', + 'method_argument_space', + 'object_operator', + 'php_closing_tag', + 'remove_lines_between_uses', + 'short_array_syntax', + 'short_tag', + 'standardize_not_equal', + 'trailing_spaces', + 'unused_use', + 'visibility', + 'whitespacy_lines', + ) +); +$config->finder($finder); +return $config; diff --git a/composer.json b/composer.json index 7c80e63..ceda107 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,12 @@ }, "autoload": { "psr-4": { - "HumusAmqpModule\\": "src/HumusAmqpModule/" + "HumusAmqpModule\\": "src/", + "HumusAmqpModuleTest\\": "tests/" + } - } + }, + "bin": [ + "bin/humus-amqp" + ] } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8422efd..e01362b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,7 +11,7 @@ syntaxCheck="true" > - ./tests/HumusAmqpModuleTest + ./tests diff --git a/src/HumusAmqpModule/Console/Input/RequestInput.php b/src/Console/Input/RequestInput.php similarity index 100% rename from src/HumusAmqpModule/Console/Input/RequestInput.php rename to src/Console/Input/RequestInput.php diff --git a/src/HumusAmqpModule/Console/Output/PropertyOutput.php b/src/Console/Output/PropertyOutput.php similarity index 100% rename from src/HumusAmqpModule/Console/Output/PropertyOutput.php rename to src/Console/Output/PropertyOutput.php diff --git a/src/HumusAmqpModule/Container/CliFactory.php b/src/Container/CliFactory.php similarity index 100% rename from src/HumusAmqpModule/Container/CliFactory.php rename to src/Container/CliFactory.php diff --git a/src/HumusAmqpModule/Module.php b/src/Module.php similarity index 100% rename from src/HumusAmqpModule/Module.php rename to src/Module.php diff --git a/tests/Container/CliFactoryTest.php b/tests/Container/CliFactoryTest.php new file mode 100644 index 0000000..45fca89 --- /dev/null +++ b/tests/Container/CliFactoryTest.php @@ -0,0 +1,48 @@ + + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. + */ + +declare (strict_types=1); + +namespace HumusAmqpModuleTest\Container; + +use HumusAmqpModule\Container\CliFactory; +use Interop\Container\ContainerInterface; +use PHPUnit_Framework_TestCase as TestCase; +use Symfony\Component\Console\Application; + +/** + * Class CliFactoryTest + * @package HumusAmqpModuleTest\Container + */ +class CliFactoryTest extends TestCase +{ + /** + * @test + */ + public function it_creates_console_runner() + { + $container = $this->prophesize(ContainerInterface::class); + + $factory = new CliFactory(); + $runner = $factory($container->reveal()); + + $this->assertInstanceOf(Application::class, $runner); + } +} \ No newline at end of file