Skip to content

Commit

Permalink
Merge pull request #4 from ibrahimgunduz34/fix/ci-config
Browse files Browse the repository at this point in the history
Fix/ci config
  • Loading branch information
ibrahimgunduz34 committed Nov 30, 2019
2 parents 74cea03 + ae8c74f commit bed4d32
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
21 changes: 0 additions & 21 deletions .travis.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: php

php:
# - 7.4
- 7.3
- 7.2
- 7.1
# - 7.0
# - 5.6

before_script:
- phpenv rehash
- composer install --dev

script:
# - find ./src/ -name "*.php" -exec php -l {} \;
- vendor/bin/phpunit
7 changes: 5 additions & 2 deletions Matcher/MatcherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public function create($scenarioRules)
self::MATCHER_FIRST,
self::MATCHER_LAST
];
if (!in_array(strtolower(reset(array_keys($scenarioRules))), $matchers)) {

$matchersInScenario = array_keys($scenarioRules);
if (!in_array(strtolower(reset($matchersInScenario)), $matchers)) {
$scenarioRules = ['default' => $scenarioRules];
}
}
Expand All @@ -50,7 +52,8 @@ public function create($scenarioRules)
private function createMatcher($scenarioRules)
{
$rules = reset($scenarioRules);
$matcherType = reset(array_keys($scenarioRules));
$keys = array_keys($scenarioRules);
$matcherType = reset($keys);
$operator = $this->operatorFactory->create($rules);

switch ($matcherType) {
Expand Down
3 changes: 2 additions & 1 deletion Operator/OperatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private function createComparisionOperator($field, $condition)
if (count($condition) > 1) {
throw new InvalidConfigurationException(sprintf('Invalid rule definition %s => %s', $field, $condition));
}
$operatorType = reset(array_keys($condition));
$operatorTypes = array_keys($condition);
$operatorType = reset($operatorTypes);
$value = $condition[$operatorType];

switch ($operatorType) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/maria.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:
maria.matcher.last.class: SweetCode\MariaBundle\Matcher\LastMatcher
maria.matcher.none.class: SweetCode\MariaBundle\Matcher\NoneMatcher

maria.service_factory.matcher.class: SweetCode\MariaBundle\MAtcher\MatcherFactory
maria.service_factory.matcher.class: SweetCode\MariaBundle\Matcher\MatcherFactory
maria.service_factory.operator.class: SweetCode\MariaBundle\Operator\OperatorFactory

services:
Expand Down
15 changes: 10 additions & 5 deletions Tests/DependencyInjection/MariaExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace SweetCode\MariaBundle\Tests;

use PHPUnit\Exception;
use PHPUnit\Framework\TestCase;
use SweetCode\MariaBundle\DependencyInjection\MariaExtension;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
Expand Down Expand Up @@ -38,12 +39,13 @@ public function testTriggerAndActionEvents()
$triggerEvent = $container->getDefinition($triggerEventServiceId);
$this->assertEquals('%maria.event_listener.trigger.class%', $triggerEvent->getClass());
$this->assertTrue($triggerEvent->hasTag('kernel.event_listener'));
$tag = $triggerEvent->getTag('kernel.event_listener');
$this->assertEquals(
[
'event' => 'test.event',
'method' => 'onTrigger'
],
reset($triggerEvent->getTag('kernel.event_listener'))
reset($tag)
);

$actionHandlerId = 'maria.handler.test_scenario.SweetCode\MariaBundle\Tests\Stub\ValidActionHandler';
Expand All @@ -53,9 +55,12 @@ public function testTriggerAndActionEvents()

public function testActionEventImplementationValidation()
{
$this->expectException(InvalidConfigurationException::class);
$this->expectDeprecationMessage(
'Handler class needs to implement onAction method');
$this->getContainer('bad_action_event_implementation.yaml');
try {
$this->getContainer('bad_action_event_implementation.yaml');
} catch (\Exception $exception) {
$this->assertInstanceOf(InvalidConfigurationException::class, $exception);
$this->assertEquals('Handler class needs to implement onAction method', $exception->getMessage());
}

}
}
9 changes: 5 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "./vendor/autoload.php">
<testsuite>
<directory>Tests</directory>
</testsuite>
<testsuites>
<testsuite name="MariaBundle">
<directory>Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
Expand Down

0 comments on commit bed4d32

Please sign in to comment.