Skip to content

Commit 7277c22

Browse files
authored
Merge pull request #1 from event-engine/bugfix/message-name-validation
Fix backslash in message name regex
2 parents a18bde5 + 87eb7a2 commit 7277c22

6 files changed

+91
-2
lines changed

.coveralls.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# for php-coveralls
2+
service_name: travis-ci
3+
coverage_clover: build/logs/clover.xml

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
composer.lock
3-
vendor
3+
vendor
4+
.php_cs
5+
.php_cs.cache

.travis.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
language: php
2+
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: 7.2
7+
env:
8+
- DEPENDENCIES=""
9+
- EXECUTE_CS_CHECK=true
10+
- TEST_COVERAGE=true
11+
12+
- php: 7.3
13+
env:
14+
- DEPENDENCIES=""
15+
- EXECUTE_CS_CHECK=false
16+
- TEST_COVERAGE=false
17+
18+
cache:
19+
directories:
20+
- $HOME/.composer/cache
21+
- $HOME/.php-cs-fixer
22+
- $HOME/.local
23+
24+
before_script:
25+
- mkdir -p "$HOME/.php-cs-fixer"
26+
- phpenv config-rm xdebug.ini
27+
- composer self-update
28+
- composer update --prefer-source $DEPENDENCIES
29+
30+
script:
31+
- 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
32+
# - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
33+
# - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/docheader check examples/ src/ tests/; fi
34+
35+
after_success:
36+
- if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi
37+
38+
notifications:
39+
webhooks:
40+
urls:
41+
- https://webhooks.gitter.im/e/61c75218816eebde4486
42+
on_success: change # options: [always|never|change] default: always
43+
on_failure: always # options: [always|never|change] default: always
44+
on_start: never # options: [always|never|change] default: always

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
}
4040
},
4141
"prefer-stable": true,
42+
"minimum-stability": "dev",
4243
"scripts": {
4344
"check": [
4445
"@cs",

src/GenericSchemaMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static function assertUuid(string $uuid): void
253253

254254
public static function assertMessageName($messageName): void
255255
{
256-
if (! \preg_match('/^[A-Za-z0-9_.-\/]+$/', $messageName)) {
256+
if (! \preg_match('/^[A-Za-z\/0-9_\.\-\\\\]+$/', $messageName)) {
257257
throw new RuntimeException('message_name is invalid');
258258
}
259259
}

tests/GenericSchemaMessageTest.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* This file is part of even-engine/php-messaging.
4+
* (c) 2018-2019 prooph software GmbH <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
namespace EventEngineTest\Messaging;
13+
14+
use EventEngine\Messaging\GenericSchemaMessage;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class GenericSchemaMessageTest extends TestCase
18+
{
19+
public function providerForMessageName(): array
20+
{
21+
return [
22+
[self::class],
23+
['MyAwesomeMessage'],
24+
['1234'],
25+
['My1234'],
26+
];
27+
}
28+
29+
/**
30+
* @test
31+
* @dataProvider providerForMessageName
32+
* @param $messageName
33+
*/
34+
public function it_asserts_message_name($messageName): void
35+
{
36+
GenericSchemaMessage::assertMessageName($messageName);
37+
$this->assertTrue(true);
38+
}
39+
}

0 commit comments

Comments
 (0)