Beispiel #1
0
 public function testGetColumn()
 {
     $table = new TableNode(array(array('username', 'password'), array('everzet', 'qwerty'), array('antono', 'pa$sword')));
     $this->assertEquals(array('username', 'everzet', 'antono'), $table->getColumn(0));
     $this->assertEquals(array('password', 'qwerty', 'pa$sword'), $table->getColumn(1));
     $table = new TableNode(array(array('username'), array('everzet'), array('antono')));
     $this->assertEquals(array('username', 'everzet', 'antono'), $table->getColumn(0));
 }
Beispiel #2
0
 /**
  * Checks that the given list of files return a 200 OK status code.
  *
  * @param \Behat\Gherkin\Node\TableNode $files
  *   The list of files that should be downloadable, relative to the base URL.
  *
  * @throws \Behat\Mink\Exception\ExpectationException
  *   Thrown when a file could not be downloaded.
  *
  * @Then the following files can be downloaded:
  */
 public function assertFilesDownloadable(TableNode $files)
 {
     $client = new Client();
     foreach ($files->getColumn(0) as $file) {
         if ($client->head($this->locatePath($file))->getStatusCode() != 200) {
             throw new ExpectationException("File {$file} could not be downloaded.");
         }
     }
 }
 /**
  * @Then the admin menu should appear as
  */
 public function theAdminMenuShouldAppearAs(TableNode $table)
 {
     $adminMenu = $this->adminPage->getMenu();
     $topLevel = $adminMenu->getTopLevelMenuItems();
     $actualHash = array();
     foreach ($topLevel as $actualMenuName) {
         $actualHash[] = array($actualMenuName);
     }
     $actualTableNode = new TableNode($actualHash);
     if (count($topLevel) != count($table->getRows())) {
         throw new \Exception("Number of rows do not match. Found: \n" . $actualTableNode);
     }
     $expected = $table->getColumn(0);
     foreach ($topLevel as $index => $actualMenuName) {
         $expectedMenuName = $expected[$index];
         if (!preg_match("/{$expectedMenuName}/", $actualMenuName)) {
             throw new \Exception(sprintf('Expected "%s" but found "%s":' . "\n" . $actualTableNode, $expectedMenuName, $actualMenuName));
         }
     }
 }
 /**
  * @Then Process of workflow with the alias :entryAlias has the below steps:
  *
  * @param string          $entryAlias
  * @param TableNode $steps
  *
  * @throws \RuntimeException
  */
 public function validateCurrentSteps($entryAlias, TableNode $steps)
 {
     $entryId = $this->getEntryIdByAlias($entryAlias);
     $currentSteps = $this->getWorkflowManager()->getConfiguration()->getWorkflowStore()->findCurrentSteps($entryId);
     $actualCurrentSteps = [];
     foreach ($currentSteps as $currentStep) {
         $actualCurrentSteps[(int) $currentStep->getStepId()] = $currentStep;
     }
     $stepsColumn = $steps->getColumn(0);
     if (count($stepsColumn) < 2 || 'stepId' !== array_shift($stepsColumn)) {
         $errMsg = 'Incorrect step id list';
         throw new \RuntimeException($errMsg);
     }
     foreach ($stepsColumn as $currentStepFromColumn) {
         $currentStepFromColumn = (int) $currentStepFromColumn;
         if (!array_key_exists($currentStepFromColumn, $actualCurrentSteps)) {
             $errMsg = sprintf('Step not found %s', $currentStepFromColumn);
             throw new \RuntimeException($errMsg);
         }
     }
     if (count($actualCurrentSteps) !== count($stepsColumn)) {
         throw new \RuntimeException('there are extra currentSteps ');
     }
 }