Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
fix: lint + standards (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigue Villetard committed Aug 5, 2016
1 parent 8ed6f1c commit ecc1696
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@
"Gorghoa\\ScenarioStateBehatExtension\\": "src/",
"Symfony\\Component\\Process\\": "vendor/symfony/process/"
}
},
"autoload-dev": {
"psr-4": {
"Gorghoa\\ScenarioStateBehatExtension\\TestApp\\": "testapp/"
}
}
}
6 changes: 5 additions & 1 deletion src/ScenarioStateArgumentOrganiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ public function __construct(ArgumentOrganiser $organiser, ScenarioStateInitializ
public function organiseArguments(ReflectionFunctionAbstract $function, array $match)
{
$i = array_slice(array_keys($match), -1, 1)[0];
$paramsKeys = array_map(function ($element) {
$paramsKeys = array_map(function($element) {
return $element->name;
}, $function->getParameters());

$store = $this->store->getStore();

if (!($function instanceof \ReflectionMethod)) {
return $this->baseOrganiser->organiseArguments($function, $match);
}

/** @var ScenarioStateArgument[] $annotations */
$annotations = $this->reader->getMethodAnnotations($function);
foreach ($annotations as $annotation) {
Expand Down
7 changes: 6 additions & 1 deletion testapp/Gorilla.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Gorghoa\ScenarioStateBehatExtension\TestApp;

/*
* This file is part of the ScenarioStateBehatExtension project.
*
Expand All @@ -16,7 +18,10 @@ class Gorilla
{
private $banana;

public function setBanana(array $banana)
/**
* @param string $banana
*/
public function setBanana($banana)
{
$this->banana = $banana;
}
Expand Down
19 changes: 13 additions & 6 deletions testapp/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@
* file that was distributed with this source code.
*/

require_once __DIR__.'/../../autoload.php';

use Gorghoa\ScenarioStateBehatExtension\Annotation\ScenarioStateArgument;
use Gorghoa\ScenarioStateBehatExtension\Context\ScenarioStateAwareContext;
use Gorghoa\ScenarioStateBehatExtension\ScenarioStateInterface;
use Gorghoa\ScenarioStateBehatExtension\TestApp\Gorilla;

/**
* @author Rodrigue Villetard <rodrigue.villetard@gmail.com>
*/
class FeatureContext implements ScenarioStateAwareContext
{
/**
* @beforeSuite
*/
public static function setUpSuite()
{
require_once __DIR__.'/../../autoload.php';
}

/**
* @var ScenarioStateInterface
*/
Expand All @@ -35,7 +42,7 @@ public function setScenarioState(ScenarioStateInterface $scenarioState)
*/
public function takeBanana()
{
$this->scenarioState->provideStateFragment('scenarioBanana', ['Yammy Banana']);
$this->scenarioState->provideStateFragment('scenarioBanana', 'Yammy Banana');
}

/**
Expand All @@ -47,7 +54,7 @@ public function takeBanana()
*/
public function giveBananaToGorilla($scenarioBanana)
{
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, ['Yammy Banana']);
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana');
$gorilla = new Gorilla();
$gorilla->setBanana($scenarioBanana);
$this->scenarioState->provideStateFragment('scenarioGorilla', $gorilla);
Expand All @@ -64,7 +71,7 @@ public function giveBananaToGorilla($scenarioBanana)
*/
public function gorillaHasBanana($scenarioBanana, Gorilla $gorilla)
{
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, ['Yammy Banana']);
\PHPUnit_Framework_Assert::assertEquals($gorilla->getBanana(), ['Yammy Banana']);
\PHPUnit_Framework_Assert::assertEquals($scenarioBanana, 'Yammy Banana');
\PHPUnit_Framework_Assert::assertEquals($gorilla->getBanana(), 'Yammy Banana');
}
}
6 changes: 3 additions & 3 deletions tests/ScenarioStateArgumentOrganiserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ protected function setUp()
public function testOrganiseArguments()
{
$this->functionMock->getParameters()->willReturn([
(object)['name' => 'scenarioBanana'],
(object)['name' => 'gorilla'],
(object)['name' => 'foo'],
(object) ['name' => 'scenarioBanana'],
(object) ['name' => 'gorilla'],
(object) ['name' => 'foo'],
])->shouldBeCalledTimes(1);

$this->initializerMock->getStore()->willReturn($this->storeMock->reveal())->shouldBeCalledTimes(1);
Expand Down

0 comments on commit ecc1696

Please sign in to comment.