Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Created July 11, 2009 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oelmekki/145243 to your computer and use it in GitHub Desktop.
Save oelmekki/145243 to your computer and use it in GitHub Desktop.
<?php
/**
* PHPSpec
*
* LICENSE
*
* This file is subject to the GNU Lesser General Public License Version 3
* that is bundled with this package in the file LICENSE.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/lgpl-3.0.txt
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@phpspec.org so we can send you a copy immediately.
*
* @category PHPSpec
* @package PHPSpec
* @copyright Copyright (c) 2007 Pádraic Brady, Travis Swicegood
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
/**
* @file HasSelector.php
* @package PHPSpec
* @copyright Copyright (c) 2009 Olivier El Mekki
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
class PHPSpec_Matcher_HaveSelector implements PHPSpec_Matcher_Interface
{
protected $_expected = null;
protected $_actual = null;
public function __construct($expected)
{
$this->_expected = $expected;
}
public function matches($actual)
{
$this->_actual = $actual;
return (bool) $this->_actual->hasSelector( $this->_expected );
}
public function getFailureMessage()
{
return 'expected match for ' . strval($this->_expected) . ' css selector to be true, got false (using hasSelector())';
}
public function getNegativeFailureMessage()
{
return 'expected no match for ' . strval($this->_expected) . ' css selector to be false, got true (using hasSelector())';
}
public function getDescription()
{
return 'match ' . strval($this->_expected) . ' css selector expression';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment