Skip to content

Commit

Permalink
Merge bdb91ea into 9e395dd
Browse files Browse the repository at this point in the history
  • Loading branch information
kilip committed Jun 12, 2019
2 parents 9e395dd + bdb91ea commit d69150e
Show file tree
Hide file tree
Showing 96 changed files with 1,619 additions and 471 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/build/
composer.lock
composer.lock
.php_cs.cache
2 changes: 1 addition & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the doyo/behat-code-coverage project.
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
Expand Down
44 changes: 44 additions & 0 deletions bin/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

#!/usr/bin/env bash

set -e

if (( "$#" != 1 ))
then
echo "Tag has to be provided"

exit 1
fi

BRANCH="master"
VERSION=$1

# Always prepend with "v"
if [[ $VERSION != v* ]]
then
VERSION="v$VERSION"
fi

for REMOTE in code-coverage-bridge behat-code-coverage phpspec-code-coverage
do
echo ""
echo ""
echo "Releasing $REMOTE";

TMP_DIR="/tmp/code-coverage-split"
REMOTE_URL="git@github.com:doyolabs/$REMOTE.git"

rm -rf $TMP_DIR;
mkdir $TMP_DIR;

(
cd $TMP_DIR;

git clone $REMOTE_URL .
git checkout "$BRANCH";

git tag -s $VERSION
git push origin --tags
)
done
23 changes: 23 additions & 0 deletions bin/split
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -x
set -e

BRANCH=$1

function split()
{
SHA1=`./bin/splitsh-lite --prefix=$1`
git push $2 "$SHA1:refs/heads/$BRANCH" -f
}

function remote()
{
git remote add $1 $2 || true
}

git pull origin $BRANCH

remote code-coverage-bridge git@github.com:doyolabs/code-coverage-bridge.git
remote behat-code-coverage git@github.com:doyolabs/behat-code-coverage.git
remote phpspec-code-coverage git@github.com:doyolabs/phpspec-code-coverage.git
Binary file added bin/splitsh-lite
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"psr-4": {
"Spec\\Doyo\\Bridge\\CodeCoverage\\": "src/code-coverage/Spec",
"Spec\\Doyo\\Behat\\CodeCoverage\\": "src/behat-extension/Spec",
"Spec\\Doyo\\PhpSpec\\CodeCoverage\\": "src/php-extension/Spec"
"Spec\\Doyo\\PhpSpec\\CodeCoverage\\": "src/phpspec-extension/Spec"
}
},
"replace": {
Expand Down
4 changes: 4 additions & 0 deletions src/behat-extension/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitignore export-ignore
.travis.yml export-ignore
Spec export-ignore
composer.lock export-ignore
14 changes: 11 additions & 3 deletions src/behat-extension/Compiler/CoveragePass.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Doyo\Behat\CodeCoverage\Compiler;
declare(strict_types=1);

namespace Doyo\Behat\CodeCoverage\Compiler;

use Doyo\Behat\CodeCoverage\Controller\CliController;
use Doyo\Behat\CodeCoverage\Listener\CoverageListener;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -20,6 +28,6 @@ public function process(ContainerBuilder $container)
$listener->addArgument($container->getParameterBag()->get('doyo.coverage_enabled'));
$listener->addTag('event_dispatcher.subscriber');

$container->setDefinition('doyo.coverage.listener',$listener);
$container->setDefinition('doyo.coverage.listener', $listener);
}
}
11 changes: 11 additions & 0 deletions src/behat-extension/Controller/CliController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Doyo\Behat\CodeCoverage\Controller;

use Behat\Testwork\Cli\Controller;
Expand Down
18 changes: 13 additions & 5 deletions src/behat-extension/Extension.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Doyo\Behat\CodeCoverage;

use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Doyo\Behat\CodeCoverage\Compiler\CoveragePass;
use Doyo\Behat\CodeCoverage\Controller\CliController;
use Doyo\Behat\CodeCoverage\Listener\CoverageListener;
use Doyo\Bridge\CodeCoverage\Configuration;
Expand Down Expand Up @@ -44,7 +53,7 @@ public function load(ContainerBuilder $container, array $config)
$definition = new Definition(CliController::class);
$definition->setPublic(true);
$definition->addTag('cli.controller', ['priority' => 80000]);
$container->setDefinition('doyo.coverage.cli_controller',$definition);
$container->setDefinition('doyo.coverage.cli_controller', $definition);

// load listener
$coverageContainer = (new ContainerFactory($config, true))->getContainer();
Expand All @@ -54,16 +63,15 @@ public function load(ContainerBuilder $container, array $config)
$container->set('doyo.coverage.container', $coverageContainer);
$container->set('doyo.coverage', $coverageContainer->get('coverage'));

$input = $container->get('cli.input');
$input = $container->get('cli.input');
$coverageEnabled = $input->hasParameterOption(['--coverage'], true);
$container->setParameter('doyo.coverage_enabled', $coverageEnabled);


$listener = new Definition(CoverageListener::class);
$listener->addArgument(new Reference('doyo.coverage'));
$listener->addArgument($container->getParameterBag()->get('doyo.coverage_enabled'));
$listener->addTag('event_dispatcher.subscriber');

$container->setDefinition('doyo.coverage.listener',$listener);
$container->setDefinition('doyo.coverage.listener', $listener);
}
}
21 changes: 21 additions & 0 deletions src/behat-extension/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT license

Copyright (c) 2018-present Anthonius Munthi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
30 changes: 18 additions & 12 deletions src/behat-extension/Listener/CoverageListener.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Doyo\Behat\CodeCoverage\Listener;

use Behat\Behat\EventDispatcher\Event\ExampleTested;
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
use Behat\Behat\Hook\Scope\ScenarioScope;
use Behat\Testwork\EventDispatcher\Event\AfterTested;
use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted;
use Behat\Testwork\Tester\Result\TestResult;
use Doyo\Behat\Coverage\Event\CoverageEvent;
use Doyo\Bridge\CodeCoverage\CodeCoverageInterface;
use Doyo\Bridge\CodeCoverage\TestCase;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -28,10 +37,9 @@ class CoverageListener implements EventSubscriberInterface
public function __construct(
CodeCoverageInterface $coverage,
bool $enabled
)
{
) {
$this->coverage = $coverage;
$this->enabled = $enabled;
$this->enabled = $enabled;
}

public static function getSubscribedEvents()
Expand All @@ -48,7 +56,7 @@ public static function getSubscribedEvents()

public function refresh()
{
if(!$this->enabled){
if (!$this->enabled) {
return;
}

Expand All @@ -57,7 +65,7 @@ public function refresh()

public function start(ScenarioTested $scenarioTested)
{
if(!$this->enabled){
if (!$this->enabled) {
return;
}

Expand All @@ -70,7 +78,7 @@ public function start(ScenarioTested $scenarioTested)

public function stop(AfterTested $tested)
{
if(!$this->enabled){
if (!$this->enabled) {
return;
}

Expand All @@ -80,20 +88,18 @@ public function stop(AfterTested $tested)
TestResult::SKIPPED => TestCase::RESULT_SKIPPED,
TestResult::PENDING => TestCase::RESULT_SKIPPED,
];
$result = $map[$tested->getTestResult()->getResultCode()];
$result = $map[$tested->getTestResult()->getResultCode()];
$coverage = $this->coverage;
$coverage->setResult($result);
$coverage->stop();
}

public function complete()
{
if(!$this->enabled){
if (!$this->enabled) {
return;
}

$this->coverage->complete();
}


}
20 changes: 15 additions & 5 deletions src/behat-extension/Spec/Controller/CliControllerSpec.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Spec\Doyo\Behat\CodeCoverage\Controller;

use Behat\Testwork\Cli\Controller;
Expand All @@ -10,20 +21,19 @@

class CliControllerSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(CliController::class);
}

function it_should_be_a_behat_cli_controller()
public function it_should_be_a_behat_cli_controller()
{
$this->shouldImplement(Controller::class);
}

function it_should_add_coverage_option(
public function it_should_add_coverage_option(
Command $command
)
{
) {
$command
->addOption('coverage', Argument::cetera())
->shouldBeCalledOnce();
Expand Down
16 changes: 13 additions & 3 deletions src/behat-extension/Spec/ExtensionSpec.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
<?php

/*
* This file is part of the doyo/code-coverage project.
*
* (c) Anthonius Munthi <me@itstoni.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Spec\Doyo\Behat\CodeCoverage;

use Doyo\Behat\CodeCoverage\Extension;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class ExtensionSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(Extension::class);
}

function it_should_be_a_behat_extension()
public function it_should_be_a_behat_extension()
{
$this->shouldImplement(\Behat\Testwork\ServiceContainer\Extension::class);
}
Expand Down

0 comments on commit d69150e

Please sign in to comment.