mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
30 lines
870 B
PHP
30 lines
870 B
PHP
<?php
|
|
|
|
namespace SilverStripe\ContentReview\Tests\Behat\Context;
|
|
|
|
use SilverStripe\BehatExtension\Context\SilverStripeContext;
|
|
|
|
class FeatureContext extends SilverStripeContext
|
|
{
|
|
/**
|
|
* @Given /^the "([^"]*)" select element should(| not) have an option with (a|an) "([^"]*)" label$/
|
|
* @param string $id
|
|
* @param string $should
|
|
* @param string $label
|
|
*/
|
|
public function theSelectElementShouldHaveAnOptionWithALabel($id, $should, $label)
|
|
{
|
|
$n = $should === '' ? 1 : 0;
|
|
$js = <<<JS
|
|
;let hasLabel = 0;
|
|
document.querySelectorAll('#{$id} > option').forEach(function(option) {
|
|
if (option.innerHTML == '$label') {
|
|
hasLabel = 1;
|
|
}
|
|
});
|
|
return hasLabel;
|
|
JS;
|
|
return $this->getSession()->evaluateScript($js) == $n;
|
|
}
|
|
}
|