Skip to content

Commit

Permalink
Merge pull request #1 from event-engine/bugfix/message-name-validation
Browse files Browse the repository at this point in the history
Fix backslash in message name regex
  • Loading branch information
codeliner authored Jul 22, 2019
2 parents a18bde5 + 87eb7a2 commit 7277c22
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# for php-coveralls
service_name: travis-ci
coverage_clover: build/logs/clover.xml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
composer.lock
vendor
vendor
.php_cs
.php_cs.cache
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
language: php

matrix:
fast_finish: true
include:
- php: 7.2
env:
- DEPENDENCIES=""
- EXECUTE_CS_CHECK=true
- TEST_COVERAGE=true

- php: 7.3
env:
- DEPENDENCIES=""
- EXECUTE_CS_CHECK=false
- TEST_COVERAGE=false

cache:
directories:
- $HOME/.composer/cache
- $HOME/.php-cs-fixer
- $HOME/.local

before_script:
- mkdir -p "$HOME/.php-cs-fixer"
- phpenv config-rm xdebug.ini
- composer self-update
- composer update --prefer-source $DEPENDENCIES

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; else ./vendor/bin/phpunit; fi
# - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
# - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/docheader check examples/ src/ tests/; fi

after_success:
- if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/61c75218816eebde4486
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"scripts": {
"check": [
"@cs",
Expand Down
2 changes: 1 addition & 1 deletion src/GenericSchemaMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static function assertUuid(string $uuid): void

public static function assertMessageName($messageName): void
{
if (! \preg_match('/^[A-Za-z0-9_.-\/]+$/', $messageName)) {
if (! \preg_match('/^[A-Za-z\/0-9_\.\-\\\\]+$/', $messageName)) {
throw new RuntimeException('message_name is invalid');
}
}
Expand Down
39 changes: 39 additions & 0 deletions tests/GenericSchemaMessageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* This file is part of even-engine/php-messaging.
* (c) 2018-2019 prooph software GmbH <contact@prooph.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace EventEngineTest\Messaging;

use EventEngine\Messaging\GenericSchemaMessage;
use PHPUnit\Framework\TestCase;

class GenericSchemaMessageTest extends TestCase
{
public function providerForMessageName(): array
{
return [
[self::class],
['MyAwesomeMessage'],
['1234'],
['My1234'],
];
}

/**
* @test
* @dataProvider providerForMessageName
* @param $messageName
*/
public function it_asserts_message_name($messageName): void
{
GenericSchemaMessage::assertMessageName($messageName);
$this->assertTrue(true);
}
}

0 comments on commit 7277c22

Please sign in to comment.