Commit 48ceffd5 authored by Daniel Król's avatar Daniel Król

Add first test

parent 8282d5ea
filter:
paths: [src/*]
tools:
php_sim: true
php_pdepend: true
php_analyzer: true
external_code_coverage: true
language: php
php:
- 5.6
- 7.0
- hhvm
before_script:
- travis_retry composer self-update
- travis_retry composer update --no-interaction
script:
- vendor/bin/phpunit --coverage-clover=build/logs/clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
......@@ -26,5 +26,13 @@
"psr-4": {
"Mleko\\Narrator\\Bundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Mleko\\Narrator\\Bundle\\Tests\\": "tests/"
}
},
"require-dev": {
"phpunit/phpunit": "^5.6"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite>
<directory suffix="Test.php">tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
......@@ -25,7 +25,7 @@ class NarratorExtension extends Extension
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
}
}
<?php
/**
* @package narrator-bundle
*/
namespace Mleko\Narrator\Bundle\Tests\Listener;
class ListenerServiceTest extends \PHPUnit_Framework_TestCase
{
/** @var \Symfony\Component\DependencyInjection\ContainerInterface | \PHPUnit_Framework_MockObject_MockObject */
private $container;
public function setUp()
{
$this->container = $this->getMockForAbstractClass(\Symfony\Component\DependencyInjection\ContainerInterface::class);
}
public function testServiceRetrieval()
{
$service = $this->getMockBuilder(\stdClass::class)->setMethods(['handle'])->getMock();
$service->expects($this->once())->method('handle');
$this->container->expects($this->once())->method('get')->with('mock.listener')->willReturn($service);
$listener = new \Mleko\Narrator\Bundle\Listener\ListenerService('mock.listener', $this->container);
$event = new \stdClass();
$meta = new \Mleko\Narrator\Meta($event, 'strClass', 'stdClass', $this->getMockBuilder(\Mleko\Narrator\EventSource::class)->getMockForAbstractClass());
$listener->handle($event, $meta);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment