ResponseVerifierTest.php 985 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Ratchet\RFC6455\Test\Unit\Handshake;
  3. use Ratchet\RFC6455\Handshake\ResponseVerifier;
  4. use PHPUnit\Framework\TestCase;
  5. /**
  6. * @covers Ratchet\RFC6455\Handshake\ResponseVerifier
  7. */
  8. class ResponseVerifierTest extends TestCase {
  9. /**
  10. * @var ResponseVerifier
  11. */
  12. protected $_v;
  13. public function setUp() {
  14. $this->_v = new ResponseVerifier;
  15. }
  16. public static function subProtocolsProvider() {
  17. return [
  18. [true, ['a'], ['a']]
  19. , [true, ['c', 'd', 'a'], ['a']]
  20. , [true, ['c, a', 'd'], ['a']]
  21. , [true, [], []]
  22. , [true, ['a', 'b'], []]
  23. , [false, ['c', 'd', 'a'], ['b', 'a']]
  24. , [false, ['a', 'b', 'c'], ['d']]
  25. ];
  26. }
  27. /**
  28. * @dataProvider subProtocolsProvider
  29. */
  30. public function testVerifySubProtocol($expected, $request, $response) {
  31. $this->assertEquals($expected, $this->_v->verifySubProtocol($request, $response));
  32. }
  33. }