ElementHtmlException.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of the Mink package.
  4. * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Behat\Mink\Exception;
  10. use Behat\Mink\Driver\DriverInterface;
  11. use Behat\Mink\Element\Element;
  12. use Behat\Mink\Session;
  13. /**
  14. * Exception thrown when an expectation on the HTML of an element fails.
  15. *
  16. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  17. */
  18. class ElementHtmlException extends ExpectationException
  19. {
  20. /**
  21. * Element instance.
  22. *
  23. * @var Element
  24. */
  25. protected $element;
  26. /**
  27. * Initializes exception.
  28. *
  29. * @param string $message optional message
  30. * @param DriverInterface|Session $driver driver instance
  31. * @param Element $element element
  32. * @param \Exception $exception expectation exception
  33. */
  34. public function __construct($message, $driver, Element $element, \Exception $exception = null)
  35. {
  36. $this->element = $element;
  37. parent::__construct($message, $driver, $exception);
  38. }
  39. protected function getContext()
  40. {
  41. return $this->element->getOuterHtml();
  42. }
  43. }