BindContext.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Copyright 2014 Fabian Grutschus. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. * The views and conclusions contained in the software and documentation are those
  27. * of the authors and should not be interpreted as representing official policies,
  28. * either expressed or implied, of the copyright holders.
  29. *
  30. * @author Fabian Grutschus <f.grutschus@lubyte.de>
  31. * @copyright 2014 Fabian Grutschus. All rights reserved.
  32. * @license BSD
  33. * @link http://github.com/fabiang/xmpp
  34. */
  35. namespace Fabiang\Xmpp\Integration;
  36. use Behat\Behat\Context\BehatContext;
  37. class BindContext extends BehatContext
  38. {
  39. /**
  40. * @Given /^Test response data for bind$/
  41. */
  42. public function testResponseDataForBind()
  43. {
  44. $this->getConnection()->setData(array(
  45. "<?xml version='1.0'?>"
  46. . "<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>",
  47. "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></stream:features>",
  48. "<iq id='fabiang_xmpp_1234' type='result'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>"
  49. . "<jid>test@jabber.unister.de/12345678890</jid></bind></iq>"
  50. ));
  51. }
  52. /**
  53. * @Then /^request for binding send$/
  54. */
  55. public function requestForBindingSend()
  56. {
  57. $buffer = $this->getConnection()->getBuffer();
  58. assertRegExp(
  59. '#^<iq type="set" id="fabiang_xmpp_[^"]+">'
  60. . '<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">'
  61. . '<resource></resource></bind></iq>$#',
  62. $buffer[1]
  63. );
  64. }
  65. /**
  66. * @Given /^Jid is set to options object$/
  67. */
  68. public function jidIsSetToOptionsObject()
  69. {
  70. assertSame('test@jabber.unister.de/12345678890', $this->getConnection()->getOptions()->getJid());
  71. }
  72. /**
  73. *
  74. * @return \Fabiang\Xmpp\Connection\Test
  75. */
  76. public function getConnection()
  77. {
  78. return $this->getMainContext()->getConnection();
  79. }
  80. }