From 19400d03ab24ba5b58e60424ca053aefd37d9aae Mon Sep 17 00:00:00 2001 From: Sven Kaffille Date: Thu, 17 May 2018 21:54:31 +0200 Subject: [PATCH 1/3] Changed react/socket to 0.8 Changed streams and usage of timer. Adapted unit tests. --- composer.json | 2 +- composer.lock | 420 +++++++++++++----- src/Client.php | 2 +- src/Io/InputStream.php | 30 +- src/Io/OutputStream.php | 28 +- .../Functional/Stomp/FunctionalTestCase.php | 3 +- tests/React/Tests/Stomp/ClientTest.php | 30 +- tests/React/Tests/Stomp/FactoryTest.php | 14 +- .../React/Tests/Stomp/Io/InputStreamTest.php | 6 + .../React/Tests/Stomp/Protocol/ParserTest.php | 16 +- tests/React/Tests/Stomp/TestCase.php | 5 + 11 files changed, 421 insertions(+), 135 deletions(-) diff --git a/composer.json b/composer.json index 202c286..9aaa39f 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "php": ">=5.4", "evenement/evenement": "~2.0", - "react/socket": "0.4.*", + "react/socket": "0.8.*", "react/promise": "~2.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 09dcf27..33808ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "ff2121cc38a06173915aa056aa3b7619", + "content-hash": "92e800849a690325b04a9dfd8d91b493", "packages": [ { "name": "evenement/evenement", @@ -54,30 +54,114 @@ ], "time": "2017-07-17T17:39:19+00:00" }, + { + "name": "react/cache", + "version": "v0.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "7d7da7fb7574d471904ba357b39bbf110ccdbf66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/7d7da7fb7574d471904ba357b39bbf110ccdbf66", + "reference": "7d7da7fb7574d471904ba357b39bbf110ccdbf66", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "~2.0|~1.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "time": "2018-06-25T12:52:40+00:00" + }, + { + "name": "react/dns", + "version": "v0.4.15", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "319e110a436d26a2fa137cfa3ef2063951715794" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/319e110a436d26a2fa137cfa3ef2063951715794", + "reference": "319e110a436d26a2fa137cfa3ef2063951715794", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^0.5 || ^0.4 || ^0.3", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", + "react/promise": "^2.1 || ^1.2.1", + "react/promise-timer": "^1.2", + "react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.5" + }, + "require-dev": { + "clue/block-react": "^1.2", + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "time": "2018-07-02T12:17:56+00:00" + }, { "name": "react/event-loop", - "version": "v0.4.3", + "version": "v0.5.2", "source": { "type": "git", "url": "https://github.com/reactphp/event-loop.git", - "reference": "8bde03488ee897dc6bb3d91e4e17c353f9c5252f" + "reference": "e94985d93c689c554265b01014f8c3064921ca27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/8bde03488ee897dc6bb3d91e4e17c353f9c5252f", - "reference": "8bde03488ee897dc6bb3d91e4e17c353f9c5252f", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/e94985d93c689c554265b01014f8c3064921ca27", + "reference": "e94985d93c689c554265b01014f8c3064921ca27", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "~4.8.35 || ^5.7 || ^6.4" }, "suggest": { - "ext-event": "~1.0", - "ext-libev": "*", - "ext-libevent": ">=0.1.0" + "ext-event": "~1.0 for ExtEventLoop", + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" }, "type": "library", "autoload": { @@ -89,25 +173,25 @@ "license": [ "MIT" ], - "description": "Event loop abstraction layer that libraries can use for evented I/O.", + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", "keywords": [ "asynchronous", "event-loop" ], - "time": "2017-04-27T10:56:23+00:00" + "time": "2018-04-24T11:23:06+00:00" }, { "name": "react/promise", - "version": "v2.5.1", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "62785ae604c8d69725d693eb370e1d67e94c4053" + "reference": "f4edc2581617431aea50430749db55cc3fc031b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/62785ae604c8d69725d693eb370e1d67e94c4053", - "reference": "62785ae604c8d69725d693eb370e1d67e94c4053", + "url": "https://api.github.com/repos/reactphp/promise/zipball/f4edc2581617431aea50430749db55cc3fc031b3", + "reference": "f4edc2581617431aea50430749db55cc3fc031b3", "shasum": "" }, "require": { @@ -140,33 +224,87 @@ "promise", "promises" ], - "time": "2017-03-25T12:08:31+00:00" + "time": "2018-06-13T15:59:06+00:00" + }, + { + "name": "react/promise-timer", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-timer.git", + "reference": "a11206938ca2394dc7bb368f5da25cd4533fa603" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/a11206938ca2394dc7bb368f5da25cd4533fa603", + "reference": "a11206938ca2394dc7bb368f5da25cd4533fa603", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", + "react/promise": "^2.7.0 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Promise\\Timer\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", + "homepage": "https://github.com/reactphp/promise-timer", + "keywords": [ + "async", + "event-loop", + "promise", + "reactphp", + "timeout", + "timer" + ], + "time": "2018-06-13T16:45:37+00:00" }, { "name": "react/socket", - "version": "v0.4.6", + "version": "v0.8.12", "source": { "type": "git", "url": "https://github.com/reactphp/socket.git", - "reference": "cf074e53c974df52388ebd09710a9018894745d2" + "reference": "7f7e6c56ccda7418a1a264892a625f38a5bdee0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/cf074e53c974df52388ebd09710a9018894745d2", - "reference": "cf074e53c974df52388ebd09710a9018894745d2", + "url": "https://api.github.com/repos/reactphp/socket/zipball/7f7e6c56ccda7418a1a264892a625f38a5bdee0c", + "reference": "7f7e6c56ccda7418a1a264892a625f38a5bdee0c", "shasum": "" }, "require": { - "evenement/evenement": "~2.0|~1.0", + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", "php": ">=5.3.0", - "react/event-loop": "0.4.*|0.3.*", - "react/promise": "^2.0 || ^1.1", - "react/stream": "^0.4.5" + "react/dns": "^0.4.13", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", + "react/promise": "^2.6.0 || ^1.2.1", + "react/promise-timer": "^1.4.0", + "react/stream": "^1.0 || ^0.7.1" }, "require-dev": { - "clue/block-react": "^1.1", - "phpunit/phpunit": "~4.8", - "react/socket-client": "^0.5.1" + "clue/block-react": "^1.2", + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" }, "type": "library", "autoload": { @@ -178,38 +316,38 @@ "license": [ "MIT" ], - "description": "Async, streaming plaintext TCP/IP and secure TLS socket server for React PHP", + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", "keywords": [ - "Socket" + "Connection", + "Socket", + "async", + "reactphp", + "stream" ], - "time": "2017-01-26T09:23:38+00:00" + "time": "2018-06-11T14:33:43+00:00" }, { "name": "react/stream", - "version": "v0.4.6", + "version": "v0.7.7", "source": { "type": "git", "url": "https://github.com/reactphp/stream.git", - "reference": "44dc7f51ea48624110136b535b9ba44fd7d0c1ee" + "reference": "10100896018fd847a257cd81143b8e1b7be08e40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/44dc7f51ea48624110136b535b9ba44fd7d0c1ee", - "reference": "44dc7f51ea48624110136b535b9ba44fd7d0c1ee", + "url": "https://api.github.com/repos/reactphp/stream/zipball/10100896018fd847a257cd81143b8e1b7be08e40", + "reference": "10100896018fd847a257cd81143b8e1b7be08e40", "shasum": "" }, "require": { - "evenement/evenement": "^2.0|^1.0", - "php": ">=5.3.8" + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5" }, "require-dev": { "clue/stream-filter": "~1.2", - "react/event-loop": "^0.4|^0.3", - "react/promise": "^2.0|^1.0" - }, - "suggest": { - "react/event-loop": "^0.4", - "react/promise": "^2.0" + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" }, "type": "library", "autoload": { @@ -221,12 +359,18 @@ "license": [ "MIT" ], - "description": "Basic readable and writable stream interfaces that support piping.", + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", "keywords": [ + "event-driven", + "io", + "non-blocking", "pipe", - "stream" + "reactphp", + "readable", + "stream", + "writable" ], - "time": "2017-01-25T14:44:14+00:00" + "time": "2018-01-19T15:04:38+00:00" } ], "packages-dev": [ @@ -286,37 +430,40 @@ }, { "name": "myclabs/deep-copy", - "version": "1.6.1", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" - } + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -324,20 +471,20 @@ "object", "object graph" ], - "time": "2017-04-12T18:52:22+00:00" + "time": "2017-10-19T19:58:43+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -378,25 +525,25 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.0", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585" + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/46f7e8bb075036c92695b15a1ddb6971c751e585", - "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", + "php": "^5.6 || ^7.0", + "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, @@ -423,7 +570,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-07-15T11:38:20+00:00" + "time": "2017-11-10T14:09:06+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -474,33 +621,33 @@ }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.7.6", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1|^2.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -533,7 +680,7 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2018-04-18T13:57:24+00:00" }, { "name": "phpunit/php-code-coverage", @@ -600,16 +747,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -643,7 +790,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -737,16 +884,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "1.4.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", "shasum": "" }, "require": { @@ -782,20 +929,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-12-04T08:55:13+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.23", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/78532d5269d984660080d8e0f4c99c5c2ea65ffe", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -819,8 +966,8 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" @@ -864,7 +1011,7 @@ "testing", "xunit" ], - "time": "2017-10-15T06:13:55+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1438,25 +1585,84 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-04-30T19:57:29+00:00" + }, { "name": "symfony/yaml", - "version": "v3.3.5", + "version": "v3.4.12", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "1f93a8d19b8241617f5074a123e282575b821df8" + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/1f93a8d19b8241617f5074a123e282575b821df8", - "reference": "1f93a8d19b8241617f5074a123e282575b821df8", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -1464,7 +1670,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1491,20 +1697,20 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-06-15T12:58:50+00:00" + "time": "2018-05-03T23:18:14+00:00" }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -1541,7 +1747,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/src/Client.php b/src/Client.php index 073d87c..edf3321 100644 --- a/src/Client.php +++ b/src/Client.php @@ -73,7 +73,7 @@ public function connect($timeout = 5) }); $this->on('connect', function ($client) use ($timer, $deferred) { - $timer->cancel(); + $this->loop->cancelTimer($timer); $deferred->resolve($client); }); diff --git a/src/Io/InputStream.php b/src/Io/InputStream.php index 907c206..51701f7 100644 --- a/src/Io/InputStream.php +++ b/src/Io/InputStream.php @@ -2,8 +2,9 @@ namespace React\Stomp\Io; +use Evenement\EventEmitter; use React\Stomp\Protocol\Parser; -use React\Stream\WritableStream; +use React\Stream\WritableStreamInterface; // $parser = new Parser(); // $input = new InputStream($parser); @@ -12,8 +13,9 @@ // }); // $conn->pipe($input); -class InputStream extends WritableStream implements InputStreamInterface +class InputStream extends EventEmitter implements WritableStreamInterface, InputStreamInterface { + protected $closed = false; private $buffer = ''; private $parser; @@ -32,4 +34,28 @@ public function write($data) $this->emit('frame', array($frame)); } } + + public function end($data = null) + { + if (null !== $data) { + $this->write($data); + } + $this->close(); + } + + public function isWritable() + { + return !$this->closed; + } + + public function close() + { + if ($this->closed) { + return; + } + $this->closed = true; + $this->emit('end', array($this)); + $this->emit('close', array($this)); + $this->removeAllListeners(); + } } diff --git a/src/Io/OutputStream.php b/src/Io/OutputStream.php index 1ee9427..29f8a96 100644 --- a/src/Io/OutputStream.php +++ b/src/Io/OutputStream.php @@ -2,24 +2,48 @@ namespace React\Stomp\Io; +use Evenement\EventEmitter; use React\EventLoop\LoopInterface; use React\Stomp\Protocol\Frame; -use React\Stream\ReadableStream; +use React\Stream\Util; +use React\Stream\WritableStreamInterface; // $output = new OutputStream(); // $output->pipe($conn); // $output->sendFrame($frame); -class OutputStream extends ReadableStream implements OutputStreamInterface +class OutputStream extends EventEmitter implements OutputStreamInterface { private $loop; private $paused = false; private $bufferedFrames = array(); + protected $closed = false; public function __construct(LoopInterface $loop) { $this->loop = $loop; } + + public function isReadable() + { + return !$this->closed; + } + + public function pipe(WritableStreamInterface $dest, array $options = array()) + { + Util::pipe($this, $dest, $options); + return $dest; + } + public function close() + { + if ($this->closed) { + return; + } + $this->closed = true; + $this->emit('end', array($this)); + $this->emit('close', array($this)); + $this->removeAllListeners(); + } public function sendFrame(Frame $frame) { diff --git a/tests/React/Functional/Stomp/FunctionalTestCase.php b/tests/React/Functional/Stomp/FunctionalTestCase.php index ede90be..20da42f 100644 --- a/tests/React/Functional/Stomp/FunctionalTestCase.php +++ b/tests/React/Functional/Stomp/FunctionalTestCase.php @@ -2,10 +2,11 @@ namespace React\Functional\Stomp; +use PHPUnit\Framework\TestCase as PHPUnitCase; use React\EventLoop\Factory as LoopFactory; use React\Stomp\Factory; -abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase +abstract class FunctionalTestCase extends PHPUnitCase { protected function getEventLoop() { diff --git a/tests/React/Tests/Stomp/ClientTest.php b/tests/React/Tests/Stomp/ClientTest.php index 2a51631..48ef03c 100644 --- a/tests/React/Tests/Stomp/ClientTest.php +++ b/tests/React/Tests/Stomp/ClientTest.php @@ -9,6 +9,8 @@ class ClientTest extends TestCase { + protected $capturedFrame; + /** @test */ public function connectShouldSendConnectFrame() { @@ -500,14 +502,14 @@ public function negativeAcknowledgeWithAckResolverArgumentShouldSendNackFrame() /** @test */ public function messagesShouldGetRoutedToSubscriptions() { - $capturedFrame = null; + $this->capturedFrame = null; $callback = $this->createCallableMock(); $callback ->expects($this->exactly(2)) ->method('__invoke') - ->will($this->returnCallback(function ($frame) use (&$capturedFrame) { - $capturedFrame = $frame; + ->will($this->returnCallback(function ($frame) { + $this->capturedFrame = $frame; })); $input = $this->createInputStreamMock(); @@ -522,6 +524,9 @@ public function messagesShouldGetRoutedToSubscriptions() 'this is a published message' ); $input->emit('frame', array($responseFrame)); + + $this->assertInstanceOf('React\Stomp\Protocol\Frame', $this->capturedFrame); + $this->assertFrameEquals($responseFrame, $this->capturedFrame); $responseFrame = new Frame( 'MESSAGE', @@ -530,10 +535,10 @@ public function messagesShouldGetRoutedToSubscriptions() ); $input->emit('frame', array($responseFrame)); - $this->assertInstanceOf('React\Stomp\Protocol\Frame', $capturedFrame); - $this->assertFrameEquals($responseFrame, $capturedFrame); + $this->assertInstanceOf('React\Stomp\Protocol\Frame', $this->capturedFrame); + $this->assertFrameEquals($responseFrame, $this->capturedFrame); - return array($input, $output, $client, $capturedFrame); + return array($input, $output, $client, $this->capturedFrame); } /** @@ -542,9 +547,9 @@ public function messagesShouldGetRoutedToSubscriptions() */ public function callbackShouldNotBeCalledAfterUnsubscribe($data) { - list($input, $output, $client, $capturedFrame) = $data; + list($input, $output, $client, $this->capturedFrame) = $data; - $client->unsubscribe($capturedFrame->getHeader('subscription')); + $client->unsubscribe($this->capturedFrame->getHeader('subscription')); $responseFrame = new Frame( 'MESSAGE', @@ -552,6 +557,7 @@ public function callbackShouldNotBeCalledAfterUnsubscribe($data) 'this is a published message' ); $input->emit('frame', array($responseFrame)); + $this->assertFrameNotEquals($responseFrame, $this->capturedFrame); } /** @test */ @@ -709,13 +715,15 @@ private function createLoopMockWithConnectionTimer() { $loop = $this->createLoopMock(); - $timer = $this->createMock('React\EventLoop\Timer\TimerInterface'); - $timer->expects($this->once()) - ->method('cancel'); + $timer = $this->createMock('React\EventLoop\TimerInterface'); $loop->expects($this->once()) ->method('addTimer') ->will($this->returnValue($timer)); + + $loop->expects($this->once()) + ->method('cancelTimer') + ->with($timer); return $loop; } diff --git a/tests/React/Tests/Stomp/FactoryTest.php b/tests/React/Tests/Stomp/FactoryTest.php index d26b56c..78e6a1d 100644 --- a/tests/React/Tests/Stomp/FactoryTest.php +++ b/tests/React/Tests/Stomp/FactoryTest.php @@ -18,18 +18,16 @@ public function testCreateConnection() $this->assertInstanceOf('React\Socket\Connection', $conn); } - /** @test */ + /** + * @test + * @expectedException \React\Stomp\Exception\ConnectionException + */ public function itShouldThrowAnExceptionInCaseSocketCreationFails() { $loop = $this->createMock('React\EventLoop\LoopInterface'); $factory = new Factory($loop); - - try { - $factory->createConnection(array('host' => 'localhost', 'port' => 37235)); - $this->fail('This should have raised an exception'); - } catch (ConnectionException $e) { - - } + + $factory->createConnection(array('host' => 'localhost', 'port' => 37235)); } public function testCreateClient() diff --git a/tests/React/Tests/Stomp/Io/InputStreamTest.php b/tests/React/Tests/Stomp/Io/InputStreamTest.php index cdb5b71..2f8de3c 100644 --- a/tests/React/Tests/Stomp/Io/InputStreamTest.php +++ b/tests/React/Tests/Stomp/Io/InputStreamTest.php @@ -99,7 +99,13 @@ public function closeShouldClose() /** @test */ public function writingAfterCloseShouldDoNothing() { + $callback = $this->createCallableMock(); + $callback + ->expects($this->never()) + ->method('__invoke'); + $input = new InputStream(new Parser()); + $input->on('frame', $callback); $input->close(); $input->write('whoops'); diff --git a/tests/React/Tests/Stomp/Protocol/ParserTest.php b/tests/React/Tests/Stomp/Protocol/ParserTest.php index 310c008..53b0f65 100644 --- a/tests/React/Tests/Stomp/Protocol/ParserTest.php +++ b/tests/React/Tests/Stomp/Protocol/ParserTest.php @@ -3,8 +3,10 @@ namespace React\Tests\Stomp\Protocol; use PHPUnit\Framework\TestCase; -use React\Stomp\Protocol\Parser; +use React\Stomp\Protocol\Frame; use React\Stomp\Protocol\InvalidFrameException; +use React\Stomp\Protocol\Parser; + class ParserTest extends TestCase { @@ -162,7 +164,17 @@ public function itShouldAcceptOtherFramesWithoutBody($command) $data = "$command\nfoo:bar\n\n\x00"; $parser = new Parser(); - $parser->parse($data); + $result = $parser->parse($data); + + list($frames, $data) = $parser->parse($data); + + $this->assertHasSingleFrame( + $command, + array('foo' => 'bar'), + '', + $data, + $frames + ); } public function provideFrameCommandsThatMustNotHaveABody() diff --git a/tests/React/Tests/Stomp/TestCase.php b/tests/React/Tests/Stomp/TestCase.php index 63cac67..16fd0a4 100644 --- a/tests/React/Tests/Stomp/TestCase.php +++ b/tests/React/Tests/Stomp/TestCase.php @@ -13,6 +13,11 @@ protected function assertFrameEquals(Frame $expected, Frame $frame) { $this->assertSame((string) $expected, (string) $frame); } + + protected function assertFrameNotEquals(Frame $expected, Frame $frame) + { + $this->assertNotSame((string) $expected, (string) $frame); + } protected function frameIsEqual(Frame $frame) { From d86be41ccbf640d00cb3df39271ca6a0bfb3196b Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Fri, 8 Jun 2018 11:43:35 +1000 Subject: [PATCH 2/3] remove tree package for travis build tree dependency is not found in trusty - two options to fix: 'apt update' before installing tree, or don't install it. I chose the latter because it does not look like it is being used --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 130250b..25dfd18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ before_script: sudo service rabbitmq-server start; fi - if [ "$STOMP_PROVIDER" = 'activemq' ]; then - sudo apt install activemq tree; + sudo apt install activemq; sudo cp tests/utils/activemq.xml /etc/activemq/instances-available/main/; sudo ln -s /etc/activemq/instances-available/main /etc/activemq/instances-enabled/main; sudo service activemq start; From 508e93fb454ed946ac31f8903b1b8a4a8893a74e Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Fri, 8 Jun 2018 15:34:09 +1000 Subject: [PATCH 3/3] another blind fix for travis build failure I was able to somewhat replicate the activemq install issue with the ubuntu:trusty docker image, and an 'apt update' resolved it --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 25dfd18..0a88ea2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ before_script: sudo service rabbitmq-server start; fi - if [ "$STOMP_PROVIDER" = 'activemq' ]; then + sudo apt update; sudo apt install activemq; sudo cp tests/utils/activemq.xml /etc/activemq/instances-available/main/; sudo ln -s /etc/activemq/instances-available/main /etc/activemq/instances-enabled/main;