当前位置: 首页>>代码示例>>PHP>>正文


PHP TableNode::getRowsHash方法代码示例

本文整理汇总了PHP中Behat\Gherkin\Node\TableNode::getRowsHash方法的典型用法代码示例。如果您正苦于以下问题:PHP TableNode::getRowsHash方法的具体用法?PHP TableNode::getRowsHash怎么用?PHP TableNode::getRowsHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Behat\Gherkin\Node\TableNode的用法示例。


在下文中一共展示了TableNode::getRowsHash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: iMakeARequestToWithTheFollowing

 /**
  * @When /^I make a request to "([^"]*)" with the following:$/
  */
 public function iMakeARequestToWithTheFollowing($url, TableNode $table)
 {
     $client = new Client();
     $request = $client->post($this->locatePath($url), array(), $table->getRowsHash());
     $response = $request->send();
     $this->currentResponse = $response;
 }
开发者ID:rachid804,项目名称:oauth,代码行数:10,代码来源:ApiContext.php

示例2: createExternalUser

 /**
  * @Given /^the external "([^"]*)" user:$/
  */
 public function createExternalUser($service, TableNode $table)
 {
     $external_user = new ExternalUser();
     $external_user->setService(strtolower($service));
     $em = $this->getEntityManager();
     foreach ($table->getRowsHash() as $field => $value) {
         switch ($field) {
             case 'name':
                 $external_user->setName($value);
                 break;
             case 'id':
                 $external_user->setRemoteId($value);
                 break;
             case 'email':
                 $external_user->setEmail($value);
                 break;
             case 'username':
                 $external_user->setUsername($value);
                 break;
             case 'picture':
                 $external_user->setProfilePictureUrl($value);
                 break;
             case 'user':
                 $user = $em->getRepository('ActsCamdramSecurityBundle:User')->findOneByEmail($value);
                 $external_user->setUser($user);
                 break;
         }
     }
     $em->persist($external_user);
     $em->flush();
 }
开发者ID:dstansby,项目名称:camdram,代码行数:34,代码来源:UserContext.php

示例3: theFollowingJobConfiguration

 /**
  * @param string    $code
  * @param TableNode $table
  *
  * @Given /^the following job "([^"]*)" configuration:$/
  */
 public function theFollowingJobConfiguration($code, TableNode $table)
 {
     $jobInstance = $this->getFixturesContext()->getJobInstance($code);
     $configuration = $jobInstance->getRawParameters();
     foreach ($table->getRowsHash() as $property => $value) {
         $value = $this->replacePlaceholders($value);
         if (in_array($value, ['yes', 'no'])) {
             $value = 'yes' === $value;
         }
         if ('filters' === $property) {
             $value = json_decode($value, true);
         }
         $configuration[$property] = $value;
     }
     /** @var JobRegistry $jobRegistry */
     $jobRegistry = $this->getMainContext()->getContainer()->get('akeneo_batch.job.job_registry');
     $job = $jobRegistry->get($jobInstance->getJobName());
     /** @var JobParametersFactory $jobParamsFactory */
     $jobParamsFactory = $this->getMainContext()->getContainer()->get('akeneo_batch.job_parameters_factory');
     $jobParams = $jobParamsFactory->create($job, $configuration);
     /** @var JobParametersValidator $jobParamsValidator */
     $jobParamsValidator = $this->getMainContext()->getContainer()->get('akeneo_batch.job.job_parameters_validator');
     $violations = $jobParamsValidator->validate($job, $jobParams, ['Default']);
     if ($violations->count() > 0) {
         $messages = [];
         /** @var ConstraintViolationInterface $violation */
         foreach ($violations as $violation) {
             $messages[] = $violation->getMessage();
         }
         throw new \InvalidArgumentException(sprintf('The parameters "%s" are not valid for the job "%s" due to violations "%s"', print_r($jobParams->all(), true), $job->getName(), implode(', ', $messages)));
     }
     $jobInstance->setRawParameters($jobParams->all());
     $saver = $this->getMainContext()->getContainer()->get('akeneo_batch.saver.job_instance');
     $saver->save($jobInstance);
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:41,代码来源:JobContext.php

示例4: i_add_a_question_and_i_fill_the_form_with

 /**
  * Adds a question to the questionnaire with the provided data.
  *
  * @Given /^I add a "([^"]*)" question and I fill the form with:$/
  *
  * @param string $questiontype The question type by text name to enter.
  * @param TableNode $fielddata
  */
 public function i_add_a_question_and_i_fill_the_form_with($questiontype, TableNode $fielddata)
 {
     $validtypes = array('----- Page Break -----', 'Check Boxes', 'Date', 'Dropdown Box', 'Essay Box', 'Label', 'Numeric', 'Radio Buttons', 'Rate (scale 1..5)', 'Text Box', 'Yes/No');
     if (!in_array($questiontype, $validtypes)) {
         throw new ExpectationException('Invalid question type specified.', $this->getSession());
     }
     // We get option choices as CSV strings. If we have this, modify it for use in
     // multiline data.
     $rows = $fielddata->getRows();
     $hashrows = $fielddata->getRowsHash();
     $options = array();
     if (isset($hashrows['Possible answers'])) {
         $options = explode(',', $hashrows['Possible answers']);
         $rownum = -1;
         // Find the row that contained multiline data and add line breaks. Rows are two item arrays where the
         // first is an identifier and the second is the value.
         foreach ($rows as $key => $row) {
             if ($row[0] == 'Possible answers') {
                 $row[1] = str_replace(',', "\n", $row[1]);
                 $rows[$key] = $row;
                 break;
             }
         }
         $fielddata = new TableNode($rows);
     }
     $this->execute('behat_forms::i_set_the_field_to', array('id_type_id', $questiontype));
     $this->execute('behat_forms::press_button', 'Add selected question type');
     $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $fielddata);
     $this->execute('behat_forms::press_button', 'Save changes');
 }
开发者ID:SysBind,项目名称:moodle-mod_questionnaire,代码行数:38,代码来源:behat_mod_questionnaire.php

示例5: assertNoRetrievedRecords

 /**
  * Assert no records from MakeDo request.
  *
  * @Then I should not have :type records matching the parameters:
  */
 public function assertNoRetrievedRecords($type, TableNode $parameters)
 {
     // Retrieve records.
     $this->records = $this->getMakeDo()->getRecords($type, $parameters->getRowsHash());
     if (!empty($this->records)) {
         throw new \Exception('There were records that matched the given parameters.');
     }
 }
开发者ID:chasingmaxwell,项目名称:makedo-extension,代码行数:13,代码来源:MakeDoContext.php

示例6: the_following_dataformfield_entrystate_exists

 /**
  * Creates a dataformfield entrystate instance.
  *
  * @Given /^the following dataformfield entrystate exists:$/
  * @param TableNode $data
  */
 public function the_following_dataformfield_entrystate_exists(TableNode $data)
 {
     global $DB;
     $datahash = $data->getRowsHash();
     // Get the dataform id.
     $idnumber = $datahash['dataform'];
     if (!($dataformid = $DB->get_field('course_modules', 'instance', array('idnumber' => $idnumber)))) {
         throw new Exception('The specified dataform with idnumber "' . $idnumber . '" does not exist');
     }
     $df = new \mod_dataform_dataform($dataformid);
     // Get the field or create it if does not exist.
     $params = array('dataid' => $dataformid, 'name' => $datahash['name']);
     if (!($instance = $DB->get_record('dataform_fields', $params))) {
         $field = $df->field_manager->add_field('entrystate');
     } else {
         $field = $df->field_manager->get_field($instance);
     }
     $field->name = $datahash['name'];
     // Set config (param1).
     $config = array();
     // Must have states.
     if (!empty($datahash['states'])) {
         $config['states'] = implode("\n", explode('#', trim($datahash['states'])));
         // Transitions.
         $transitions = array();
         $i = 0;
         while (isset($datahash["to{$i}"])) {
             if ($datahash["to{$i}"] === '') {
                 $i++;
                 continue;
             }
             $from = "from{$i}";
             $to = "to{$i}";
             $permission = "permission{$i}";
             $notification = "notification{$i}";
             $trans = array();
             $trans['from'] = $datahash[$from];
             $trans['to'] = $datahash[$to];
             if (!empty($datahash[$permission])) {
                 $trans['permission'] = $datahash[$permission];
             }
             if (!empty($datahash[$notification])) {
                 $trans['notification'] = $datahash[$notification];
             }
             if ($trans) {
                 $transitions[] = $trans;
             }
             $i++;
         }
         if ($transitions) {
             $config['transitions'] = $transitions;
         }
     }
     // Set param1.
     $field->param1 = $config ? base64_encode(serialize($config)) : null;
     $field->update($field->data);
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:63,代码来源:behat_dataformfield_entrystate.php

示例7: theCarWithTheIdShouldHavePropertyWithTheFollowingValues

 /**
  * @Then the car with the id :id should have property :propertyName with the following values:
  */
 public function theCarWithTheIdShouldHavePropertyWithTheFollowingValues($id, $propertyName, TableNode $values)
 {
     $car = $this->repository->find($id);
     $getter = 'get' . ucfirst(strtolower($propertyName));
     $data = $car->{$getter}();
     foreach ($values->getRowsHash() as $key => $value) {
         assertTrue(isset($data[$key]));
         assertEquals($value, $data[$key]);
     }
 }
开发者ID:justintaft01,项目名称:redis-orm,代码行数:13,代码来源:MainContext.php

示例8: i_set_global_variables_with_values

 /**
  * Sets the specified global variable. A table with | variable_name | value | is expected.
  *
  * @Given /^I set global variables with values:$/
  * @param TableNode $table
  */
 public function i_set_global_variables_with_values(TableNode $table)
 {
     global $CFG;
     if (!($data = $table->getRowsHash())) {
         return;
     }
     foreach ($data as $label => $value) {
         ${$label} = $value;
         print "\nFrom table I've set \${$label} = {${$label}}";
     }
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:17,代码来源:behat_eclassdisabledisasters.php

示例9: i_Set_The_Values_Of_The_Choice_With_The_Id_To

 /**
  * Fills the respective fields of a choice.
  *
  * @Given /^I set the values of the choice with the id (?P<choice_id>-?\d+) to:$/
  * 
  * @param integer $choiceid id of the choice
  * @param TableNode $choicedata with data for filling the choice
  */
 public function i_Set_The_Values_Of_The_Choice_With_The_Id_To($choiceid, TableNode $choicedata)
 {
     $result = new TableNode();
     $choicedatahash = $choicedata->getRowsHash();
     // The action depends on the field type.
     $steps = array();
     foreach ($choicedatahash as $locator => $value) {
         array_push($steps, new Given("I set the field \"id_choices_{$choiceid}_{$locator}\" to \"{$value}\""));
     }
     return $steps;
 }
开发者ID:andrewhancox,项目名称:moodle-mod_ratingallocate,代码行数:19,代码来源:behat_mod_ratingallocate.php

示例10: checkUserAccessToPages

 /**
  * @example
  * Given user should have an access to the following pages
  *   | page/url |
  *
  * @param string $not
  * @param TableNode $paths
  *
  * @throws \Exception
  *
  * @Given /^user should(| not) have an access to the following pages:$/
  */
 public function checkUserAccessToPages($not, TableNode $paths)
 {
     $code = empty($not) ? 200 : 403;
     $fails = [];
     foreach (array_keys($paths->getRowsHash()) as $path) {
         if (!$this->assertStatusCode($path, $code)) {
             $fails[] = $path;
         }
     }
     if (!empty($fails)) {
         throw new \Exception(sprintf('The following paths: "%s" are %s accessible!', implode(', ', $fails), $not ? '' : 'not'));
     }
 }
开发者ID:arrrtem,项目名称:TqExtension,代码行数:25,代码来源:RedirectContext.php

示例11: supplierExistsWithProduct

 /**
  * @Given /^supplier "([^"]*)" exists with product:$/
  */
 public function supplierExistsWithProduct($name, TableNode $table)
 {
     $data = $table->getRowsHash();
     $supplier = $this->supplierExists($name);
     $product = new Product($data['Name'], (double) $data['Price'], $supplier);
     if (isset($data['Description'])) {
         $product->setDescription($data['Description']);
     }
     var_dump($product->getPrice());
     $this->getEntityManager()->persist($product);
     $this->getEntityManager()->flush();
     $this->getParameterBag()->set('product', $product);
 }
开发者ID:drymek,项目名称:fcs-backend,代码行数:16,代码来源:DatabaseContext.php

示例12: configContainsValues

 /**
  * @Then /^The config should contain the following values:$/
  *
  * @param TableNode $table
  *
  * @throws \Exception
  */
 public function configContainsValues(TableNode $table)
 {
     $configFile = $this->kernel->getRootDir() . '/config/parameters.yml';
     $yaml = Yaml::parse(file_get_contents($configFile))['parameters'];
     foreach ($table->getRowsHash() as $config => $value) {
         if (!array_key_exists($config, $yaml)) {
             throw new \Exception(sprintf('Key "%s" does not exist in config file', $config));
         }
         if ($yaml[$config] != $value) {
             throw new \Exception(sprintf('Config "%s" does not match expected value. Expected "%s", got "%s"', $config, $value, $yaml[$config]));
         }
     }
 }
开发者ID:csbill,项目名称:csbill,代码行数:20,代码来源:InstallContext.php

示例13: contains

 /**
  * @example
  * I check that email for "test@example.com" contains:
  *   | subject | New email letter   |
  *   | body    | The body of letter |
  * I also check that email contains:
  *   | from    | admin@example.com  |
  *
  * @param string $to
  *   Recipient.
  * @param TableNode $values
  *   Left column - is a header key, right - value.
  *
  * @throws \RuntimeException
  *   When any message was not sent.
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  *
  * @Given /^(?:|I )check that email for "([^"]*)" contains:$/
  */
 public function contains($to, TableNode $values)
 {
     $rows = $values->getRowsHash();
     foreach ($this->getEmailMessages($to) as $message) {
         foreach ($rows as $field => $value) {
             if (empty($message[$field])) {
                 throw new \InvalidArgumentException(sprintf('Message does not contain "%s" header.', $field));
             }
             if (strpos($message[$field], $value) === false) {
                 throw new \RuntimeException(sprintf('Value of "%s" does not contain "%s".', $field, $value));
             }
         }
     }
 }
开发者ID:BR0kEN-,项目名称:TqExtension,代码行数:34,代码来源:EmailContext.php

示例14: whenGettingShareesFor

 /**
  * @When /^getting sharees for$/
  * @param \Behat\Gherkin\Node\TableNode $body
  */
 public function whenGettingShareesFor($body)
 {
     $url = '/apps/files_sharing/api/v1/sharees';
     if ($body instanceof \Behat\Gherkin\Node\TableNode) {
         $parameters = [];
         foreach ($body->getRowsHash() as $key => $value) {
             $parameters[] = $key . '=' . $value;
         }
         if (!empty($parameters)) {
             $url .= '?' . implode('&', $parameters);
         }
     }
     $this->sendingTo('GET', $url);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:18,代码来源:ShareesContext.php

示例15: the_following_dataformfield_time_exists

 /**
  * Creates a Dataform instance.
  *
  * @Given /^the following dataformfield time exists:$/
  * @param TableNode $data
  */
 public function the_following_dataformfield_time_exists(TableNode $data)
 {
     global $DB;
     $datahash = $data->getRowsHash();
     // Get the dataform id.
     $idnumber = $datahash['dataform'];
     if (!($dataformid = $DB->get_field('course_modules', 'instance', array('idnumber' => $idnumber)))) {
         throw new Exception('The specified dataform with idnumber "' . $idnumber . '" does not exist');
     }
     $df = new \mod_dataform_dataform($dataformid);
     // Get the field or create it if does not exist.
     $params = array('dataid' => $dataformid, 'name' => $datahash['name']);
     if (!($instance = $DB->get_record('dataform_fields', $params))) {
         $field = $df->field_manager->add_field('dataformview');
     } else {
         $field = $df->field_manager->get_field($instance);
     }
     // Date only.
     $field->param1 = null;
     if (!empty($datahash['date only'])) {
         $field->param1 = 1;
     }
     // Masked.
     $field->param5 = null;
     if (!empty($datahash['masked'])) {
         $field->param5 = 1;
     }
     // Start year.
     $field->param2 = null;
     if (!empty($datahash['start year'])) {
         $field->param2 = $datahash['start year'];
     }
     // stop year.
     $field->param3 = null;
     if (!empty($datahash['stop year'])) {
         $field->param3 = $datahash['stop year'];
     }
     // Display format.
     $field->param4 = null;
     if (!empty($datahash['display format'])) {
         $field->param4 = $datahash['display format'];
     }
     // Default content.
     $field->default = null;
     if (!empty($datahash['default content'])) {
         $field->default = $datahash['default content'];
     }
     $field->update($field->data);
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:55,代码来源:behat_dataformfield_time.php


注:本文中的Behat\Gherkin\Node\TableNode::getRowsHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。