/**
  * Tests that checks advanced search
  *
  * @dataProvider columnTitle
  */
 public function testAdvancedSearch($query, $userField)
 {
     $login = new Login($this);
     $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN)->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS)->submit()->openUsers();
     $users = new Users($this);
     $userData = $users->getRandomEntity();
     $login->openNavigation(array('url' => '/search/advanced-search-page'));
     //Fill advanced search input field
     $login->byId('query')->value($query . $userData[$userField]);
     $login->byId('sendButton')->click();
     $login->waitPageToLoad();
     $login->waitForAjax();
     //Check that result is not null
     $result = strtolower($userData['USERNAME']);
     $login->assertElementPresent("//div[@class='container-fluid']" . "//div[@class='search_stats alert alert-info']//h3[contains(., '{$result}')]", 'Search results does not found');
 }
 /**
  * @Then /^I should see "([^"]*)"$/
  */
 public function iShouldSee($message)
 {
     $users = new Users($this, false);
     $users->assertMessage($message)->assertTitle('Users - System');
 }
 /**
  * Tests that order in columns works correct
  *
  * @param string $columnName
  * @dataProvider columnTitle
  */
 public function testSorting($columnName)
 {
     $login = new Login($this);
     $login->setUsername(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_LOGIN)->setPassword(PHPUNIT_TESTSUITE_EXTENSION_SELENIUM_PASS)->submit();
     $users = new Users($this);
     $users->changePageSize('last');
     $columnId = $users->getColumnNumber($columnName);
     //test descending order
     $columnOrder = $users->sortBy($columnName, 'desc')->getColumn($columnId);
     if ($columnName == 'Birthday') {
         $dateArray = array();
         foreach ($columnOrder as $value) {
             $date = strtotime($value);
             $dateArray[] = $date;
         }
         $columnOrder = $dateArray;
     }
     $sortedColumnOrder = $columnOrder;
     natcasesort($sortedColumnOrder);
     $sortedColumnOrder = array_reverse($sortedColumnOrder);
     $this->assertTrue($columnOrder === $sortedColumnOrder, print_r(array('expected' => $sortedColumnOrder, 'actual' => $columnOrder), true));
     //change page size to 10 and refresh grid
     $users->changePageSize('first');
     $users->sortBy($columnName, 'asc');
     $columnOrder = $users->sortBy($columnName, 'desc')->getColumn($columnId);
     $this->assertTrue($columnOrder === array_slice($sortedColumnOrder, 0, 10), print_r(array('expected' => $sortedColumnOrder, 'actual' => $columnOrder), true));
     //test ascending order
     $users->changePageSize('last');
     $columnOrder = $users->sortBy($columnName, 'asc')->getColumn($columnId);
     if ($columnName == 'Birthday') {
         $dateArray = array();
         foreach ($columnOrder as $value) {
             $date = strtotime($value);
             $dateArray[] = $date;
         }
         $columnOrder = $dateArray;
     }
     $sortedColumnOrder = $columnOrder;
     natcasesort($sortedColumnOrder);
     $this->assertTrue($columnOrder === $sortedColumnOrder, print_r(array('expected' => $sortedColumnOrder, 'actual' => $columnOrder), true));
     //change page size to 10 and refresh grid
     $users->changePageSize('first');
     $users->sortBy($columnName, 'desc');
     $columnOrder = $users->sortBy($columnName, 'asc')->getColumn($columnId);
     $this->assertTrue($columnOrder === array_slice($sortedColumnOrder, 0, 10), print_r(array('expected' => $sortedColumnOrder, 'actual' => $columnOrder), true));
 }