/** * @Then /^I should( not)? see the input filter for "([^"]*)"$/ * * @param boolean $not * @param string $filterName * * @throws ExpectationException */ public function iShouldSeeTheInputFilterFor($not, $filterName) { $filter = $this->datagrid->getFilter($filterName); $inputVisible = $filter->isInputValueVisible(); if ('' !== $not && false !== $inputVisible || '' === $not && false === $inputVisible) { throw $this->createExpectationException(sprintf('Input for filter "%s" should%s be visible.', $filterName, $not)); } }
/** * @param string $filterName * @param mixed $values * @param string $operator * * @throws \InvalidArgumentException */ protected function filterByDate($filterName, $values, $operator) { if (!is_array($values)) { $values = [$values, $values]; } $filter = $this->datagrid->getFilter($filterName); $this->datagrid->openFilter($filter); $criteriaElt = $filter->find('css', 'div.filter-criteria'); $criteriaElt->find('css', 'select.filter-select-oro')->selectOption($operator); $datepickers = $filter->findAll('css', '.date-visual-element'); foreach ($datepickers as $i => $datepicker) { if ($datepicker->isVisible()) { $datepicker->setValue($values[$i]); } } $filter->find('css', 'button.filter-update')->click(); }
/** * @param string $filterName * @param mixed $values * @param string $operator * * @throws \InvalidArgumentException */ protected function filterByDate($filterName, $values, $operator) { if (!is_array($values)) { $values = [$values, $values]; } $filter = $this->datagrid->getFilter($filterName); if (!$filter) { throw new \InvalidArgumentException("Could not find filter for {$filterName}."); } $this->datagrid->openFilter($filter); $criteriaElt = $filter->find('css', 'div.filter-criteria'); $criteriaElt->find('css', 'select.filter-select-oro')->selectOption($operator); $script = <<<'JS' require(['jquery', 'jquery-ui'], function ($) { $inputs = $('input.hasDatepicker:visible'); $inputs.first().datepicker('setDate', $.datepicker.parseDate('yy-mm-dd', '%s')); $inputs.last().datepicker('setDate', $.datepicker.parseDate('yy-mm-dd', '%s')); }); JS; $this->getSession()->getDriver()->executeScript(vsprintf($script, $values)); $filter->find('css', 'button.filter-update')->click(); }