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


PHP Node\TableNode类代码示例

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


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

示例1: 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

示例2: ldapEntries

 /**
  * Creates entries provided in the form:
  * | cn    | attribute1    | attribute2 | attributeN |
  * | primary | value1 | value2 | valueN |
  * | ...      | ...        | ...  | ... |
  *
  * @Given /^Ldap entries:$/
  */
 public function ldapEntries(TableNode $entries)
 {
     foreach ($entries->getHash() as $entry) {
         $ldapEntry = new Entry('cn' . '=' . $entry['cn'] . ',' . $this->rootDn, $entry);
         $this->client->getEntryManager()->add($ldapEntry);
     }
 }
开发者ID:L0rD59,项目名称:behat-ldap-extension,代码行数:15,代码来源:Context.php

示例3: postsExist

 /**
  * @Given Posts exist:
  */
 public function postsExist(TableNode $table)
 {
     $postsData = $table->getHash();
     foreach ($postsData as $postData) {
         $this->processPost($postData);
     }
 }
开发者ID:johnpbloch,项目名称:WpBehatExtension,代码行数:10,代码来源:PostContext.php

示例4: lasSiguientesTaquillas

 /**
  * @When /^las siguientes taquillas:$/
  */
 public function lasSiguientesTaquillas(TableNode $table)
 {
     foreach ($table->getHash() as $item) {
         /** @var Locker $locker */
         $locker = $this->getRepository('locker')->createNew();
         $locker->setCode($item['código']);
         $locker->setStatus($this->status[$item['estado']]);
         if ($item['alquilada_a']) {
             $username = $item['alquilada_a'];
             $user = $this->getRepository('user')->findOneBy(['username' => $username]);
             if (!$user) {
                 throw new \Exception('User not found: ' . $username);
             }
             $start = new \DateTime($item['desde'] . ' days');
             $end = new \DateTime($item['hasta'] . ' days midnight');
             $renewable = isset($item['renovable']) ? $item['renovable'] : 'sí';
             /** @var Rental $rental */
             $rental = $this->getRepository('rental')->createNew();
             $rental->setStartAt($start);
             $rental->setEndAt($end);
             $rental->setUser($user);
             $rental->setLocker($locker);
             $rental->setIsRenewable($renewable === 'sí');
             $locker->setOwner($user);
             $locker->setStatus(Locker::RENTED);
             $this->getEntityManager()->persist($rental);
         }
         $this->getEntityManager()->persist($locker);
     }
     $this->getEntityManager()->flush();
 }
开发者ID:aulasoftwarelibre,项目名称:seta,代码行数:34,代码来源:LockerContext.php

示例5: i_fill_the_capabilities_form_with_the_following_permissions

 /**
  * Fills the advanced permissions form with the provided data. Expects a table with capability name and permission (Inherit/Allow/Prevent/Prohibit) columns.
  * @Given /^I fill the capabilities form with the following permissions:$/
  * @param TableNode $table
  * @return void
  */
 public function i_fill_the_capabilities_form_with_the_following_permissions($table)
 {
     // Ensure we are using the advanced view.
     // Wrapped in a try/catch to capture the exception and continue execution, we don't know if advanced mode was already enabled.
     try {
         $advancedtoggle = $this->find_button(get_string('showadvanced', 'form'));
         if ($advancedtoggle) {
             $this->getSession()->getPage()->pressButton(get_string('showadvanced', 'form'));
         }
     } catch (Exception $e) {
         // We already are in advanced mode.
     }
     // Using getRows() as we are not sure if tests writers will add the header.
     foreach ($table->getRows() as $key => $row) {
         if (count($row) !== 2) {
             throw new ExpectationException('You should specify a table with capability/permission columns', $this->getSession());
         }
         list($capability, $permission) = $row;
         // Skip the headers row if it was provided
         if (strtolower($capability) == 'capability' || strtolower($capability) == 'capabilities') {
             continue;
         }
         // Checking the permission value.
         $permissionconstant = 'CAP_' . strtoupper($permission);
         if (!defined($permissionconstant)) {
             throw new ExpectationException('The provided permission value "' . $permission . '" is not valid. Use Inherit, Allow, Prevent or Prohibited', $this->getSession());
         }
         // Converting from permission to constant value.
         $permissionvalue = constant($permissionconstant);
         // Here we wait for the element to appear and exception if it does not exists.
         $radio = $this->find('xpath', '//input[@name="' . $capability . '" and @value="' . $permissionvalue . '"]');
         $radio->click();
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:40,代码来源:behat_permissions.php

示例6: quiz_contains_the_following_questions

 /**
  * Put the specified questions on the specified pages of a given quiz.
  *
  * Give the question name in the first column, and that page number in the
  * second column. You may optionally give the desired maximum mark for each
  * question in a third column.
  *
  * @param string $quizname the name of the quiz to add questions to.
  * @param TableNode $data information about the questions to add.
  *
  * @Given /^quiz "([^"]*)" contains the following questions:$/
  */
 public function quiz_contains_the_following_questions($quizname, TableNode $data)
 {
     global $DB;
     $quiz = $DB->get_record('quiz', array('name' => $quizname), '*', MUST_EXIST);
     // The action depends on the field type.
     foreach ($data->getRows() as $questiondata) {
         if (count($questiondata) < 2 || count($questiondata) > 3) {
             throw new ExpectationException('When adding questions to a quiz, you should give 2 or three 3 things: ' . ' the question name, the page number, and optionally a the maxiumum mark. ' . count($questiondata) . ' values passed.', $this->getSession());
         }
         list($questionname, $rawpage) = $questiondata;
         if (!isset($questiondata[2]) || $questiondata[2] === '') {
             $maxmark = null;
         } else {
             $maxmark = clean_param($questiondata[2], PARAM_FLOAT);
             if (!is_numeric($questiondata[2]) || $maxmark < 0) {
                 throw new ExpectationException('When adding questions to a quiz, the max mark must be a positive number.', $this->getSession());
             }
         }
         $page = clean_param($rawpage, PARAM_INT);
         if ($page <= 0 || (string) $page !== $rawpage) {
             throw new ExpectationException('When adding questions to a quiz, the page number must be a positive integer.', $this->getSession());
         }
         $questionid = $DB->get_field('question', 'id', array('name' => $questionname), MUST_EXIST);
         quiz_add_quiz_question($questionid, $quiz, $page, $maxmark);
     }
     quiz_update_sumgrades($quiz);
 }
开发者ID:adonm,项目名称:learning,代码行数:39,代码来源:behat_mod_quiz.php

示例7: thereArePosts

 /**
  * Add these posts to this wordpress installation
  * Example: Given there are posts
  *              | post_title      | post_content              | post_status | post_author | post_date           |
  *              | Just my article | The content of my article | publish     | 1           | 2016-10-11 08:30:00 |
  *
  *
  * @Given /^there are posts$/
  */
 public function thereArePosts(TableNode $table)
 {
     foreach ($table->getHash() as $postData) {
         $postData = $this->parseArgs($postData);
         $this->insert($postData);
     }
 }
开发者ID:stephenharris,项目名称:WordPressBehatExtension,代码行数:16,代码来源:WordPressPostContext.php

示例8: assertNoSelectOptions

 /**
  * Checks that the given select field doesn't have the listed options.
  *
  * @Then I should not have the following options for :select:
  */
 public function assertNoSelectOptions($select, TableNode $options)
 {
     // Retrieve the specified field.
     if (!($field = $this->getSession()->getPage()->findField($select))) {
         throw new ExpectationException("Field '{$select}' not found.", $this->getSession());
     }
     // Check that the specified field is a <select> field.
     $this->assertElementType($field, 'select');
     // Retrieve the options table from the test scenario and flatten it.
     $expected_options = $options->getColumnsHash();
     array_walk($expected_options, function (&$value) {
         $value = reset($value);
     });
     // Retrieve the actual options that are shown in the page.
     $actual_options = $field->findAll('css', 'option');
     // Convert into a flat list of option text strings.
     array_walk($actual_options, function (&$value) {
         $value = $value->getText();
     });
     // Check that none of the expected options are present.
     foreach ($expected_options as $expected_option) {
         if (in_array($expected_option, $actual_options)) {
             throw new ExpectationException("Option '{$expected_option}' is unexpectedly found in select list '{$select}'.", $this->getSession());
         }
     }
 }
开发者ID:kimlop,项目名称:platform-dev,代码行数:31,代码来源:FeatureContext.php

示例9: groupsMemberships

 /**
  * @Given /^groups memberships:$/
  */
 public function groupsMemberships(TableNode $table)
 {
     $memberships = $table->getHash();
     foreach ($memberships as $membership) {
         // Find group node.
         $group_node = $membership['group'];
         foreach ($this->nodes as $node) {
             if ($node->type == 'group' && $node->title == $group_node) {
                 $group_node = $node;
             }
         }
         // Subscribe nodes and users to group.
         if (isset($membership['members'])) {
             $members = explode(",", $membership['members']);
             foreach ($this->users as $user) {
                 if (in_array($user->name, $members)) {
                     og_group('node', $group_node->nid, array('entity' => $user, 'entity_type' => 'user', "membership type" => OG_MEMBERSHIP_TYPE_DEFAULT));
                     // Patch till i figure out why rules are not firing.
                     if ($user->name == 'editor') {
                         og_role_grant('node', $group_node->nid, $user->uid, 4);
                     }
                 }
             }
         }
         if (isset($membership['nodes'])) {
             $content = explode(",", $membership['nodes']);
             foreach ($this->nodes as $node) {
                 if ($node->type != 'group' && in_array($node->title, $content)) {
                     og_group('node', $group_node->nid, array('entity' => $node, 'entity_type' => 'node', 'state' => OG_STATE_ACTIVE));
                 }
             }
         }
     }
 }
开发者ID:newswim,项目名称:dkan-drops-7,代码行数:37,代码来源:FeaturedContext.php

示例10: addGroupMemberships

 /**
  * Creates multiple group memberships.
  *
  * Provide group membership data in the following format:
  *
  * | user  | group     | role on group        | membership status |
  * | Foo   | The Group | administrator member | Active            |
  *
  * @Given group memberships:
  */
 public function addGroupMemberships(TableNode $groupMembershipsTable)
 {
     foreach ($groupMembershipsTable->getHash() as $groupMembershipHash) {
         if (isset($groupMembershipHash['group']) && isset($groupMembershipHash['user'])) {
             $group = $this->getGroupByName($groupMembershipHash['group']);
             $user = user_load_by_name($groupMembershipHash['user']);
             // Add user to group with the proper group permissions and status
             if ($group && $user) {
                 // Add the user to the group
                 og_group("node", $group->nid->value(), array("entity type" => "user", "entity" => $user, "membership type" => OG_MEMBERSHIP_TYPE_DEFAULT, "state" => $this->getMembershipStatusByName($groupMembershipHash['membership status'])));
                 // Grant user roles
                 $group_role = $this->getGroupRoleByName($groupMembershipHash['role on group']);
                 og_role_grant("node", $group->nid->value(), $user->uid, $group_role);
             } else {
                 if (!$group) {
                     throw new \Exception(sprintf("No group was found with name %s.", $groupMembershipHash['group']));
                 }
                 if (!$user) {
                     throw new \Exception(sprintf("No user was found with name %s.", $groupMembershipHash['user']));
                 }
             }
         } else {
             throw new \Exception(sprintf("The group and user information is required."));
         }
     }
 }
开发者ID:nucivic,项目名称:dkanextension,代码行数:36,代码来源:GroupContext.php

示例11: theFollowingHtmlResponses

 /**
  * @Given the following html response contents:
  *
  * @param TableNode $table
  */
 public function theFollowingHtmlResponses(TableNode $table)
 {
     foreach ($table->getHash() as $item) {
         $this->responseHTMLs[] = file_get_contents(__DIR__ . '/../../Resources/Fixtures/' . $item['content']);
     }
     $this->buildMockHttpClientProvider();
 }
开发者ID:jmoz,项目名称:scrape,代码行数:12,代码来源:FeatureContext.php

示例12: site_settings_set

 /**
  * Sets the specified site settings.
  * A table with | Setting label | value | is expected.
  *
  * @Given /^the following site settings are set:$/
  * @param TableNode $table
  * @throws SystemException
  */
 public function site_settings_set(TableNode $table)
 {
     $settings = array();
     foreach ($table->getHash() as $sitesetting) {
         $settings[$sitesetting['field']] = $sitesetting['value'];
     }
     // Validate the settings
     $allowsettings = array('sitename', 'lang', 'country', 'theme', 'dropdownmenu', 'homepageinfo', 'userscanchooseviewthemes', 'remoteavatars', 'userscanhiderealnames', 'searchusernames', 'searchuserspublic', 'anonymouscomments', 'loggedinprofileviewaccess', 'staffreports', 'staffstats', 'userscandisabledevicedetection', 'masqueradingreasonrequired', 'masqueradingnotified', 'showprogressbar', 'exporttoqueue', 'defaultmultipleblogs', 'searchplugin', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap', 'showselfsearchsideblock', 'showtagssideblock', 'tagssideblockmaxtags', 'viewmicroheaders', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'wysiwyg', 'sitefilesaccess', 'watchlistnotification_delay', 'skins');
     // if public views are disabled, sitemap generation must also be disabled.
     if (empty($settings['allowpublicviews'])) {
         $settings['generatesitemap'] = false;
     } else {
         // Ensure allowpublicprofiles is set as well
         $settings['allowpublicprofiles'] = 1;
     }
     // Update site settings
     $oldsearchplugin = get_config('searchplugin');
     $oldlanguage = get_config('lang');
     $oldtheme = get_config('theme');
     foreach ($allowsettings as $setting) {
         if (isset($settings[$setting]) && !set_config($setting, $settings[$setting])) {
             throw new SystemException("Can not set the option \"{$setting}\" to \"{$settings[$setting]}\"");
         }
     }
     if (isset($settings['lang']) && $oldlanguage != $settings['lang']) {
         safe_require('artefact', 'file');
         ArtefactTypeFolder::change_public_folder_name($oldlanguage, $settings['lang']);
     }
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:37,代码来源:BehatAdmin.php

示例13: theFollowingUsersExist

 /**
  * @Given the following users exist:
  */
 public function theFollowingUsersExist(TableNode $table)
 {
     /** @var \Ma27\ApiKeyAuthenticationBundle\Model\Password\PasswordHasherInterface $hasher */
     $hasher = $this->getContainer()->get('ma27_api_key_authentication.password.strategy');
     $em = $this->getEntityManager();
     $userRole = $em->getRepository('Account:Role')->findOneBy(['role' => 'ROLE_USER']);
     $adminRole = $em->getRepository('Account:Role')->findOneBy(['role' => 'ROLE_ADMIN']);
     foreach ($table->getHash() as $row) {
         $user = User::create($row['username'], $hasher->generateHash($row['password']), $row['email']);
         if (isset($row['user_id'])) {
             // there are cases where the user id should be known
             $r = new \ReflectionProperty(User::class, 'id');
             $r->setAccessible(true);
             $r->setValue($user, $row['user_id']);
         }
         if (isset($row['activation_date'])) {
             $user->getPendingActivation()->setActivationDate(new \DateTime($row['activation_date']));
         }
         if (!(isset($row['is_non_activated']) && $row['is_non_activated'] === 'true')) {
             $user->setState(User::STATE_APPROVED);
             // roles only allowed for approved users
             $user->addRole($userRole);
             if (isset($row['is_admin']) && $row['is_admin'] === 'true') {
                 $user->addRole($adminRole);
             }
         } else {
             if (isset($row['activation_key'])) {
                 $user->setActivationKey($row['activation_key']);
             }
         }
         $em->persist($user);
     }
     $em->flush();
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:37,代码来源:AppContext.php

示例14: installWordPress

 /**
  * Create a new WordPress website from scratch
  *
  * @Given /^\w+ have a vanilla wordpress installation$/
  */
 public function installWordPress(TableNode $table = null)
 {
     global $wp_rewrite;
     $name = "admin";
     $email = "an@example.com";
     $password = "test";
     $username = "admin";
     if ($table) {
         $hash = $table->getHash();
         $row = $hash[0];
         $name = $row["name"];
         $username = $row["username"];
         $email = $row["email"];
         $password = $row["password"];
     }
     $mysqli = new \Mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     $value = $mysqli->multi_query(implode("\n", array("DROP DATABASE IF EXISTS " . DB_NAME . ";", "CREATE DATABASE " . DB_NAME . ";")));
     \PHPUnit_Framework_Assert::assertTrue($value);
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     wp_install($name, $username, $email, true, '', $password);
     //This is a bit of a hack, we don't care about the notification e-mails here so clear the inbox
     //we run the risk of deleting stuff we want!
     $this->inboxFactory->getInbox($email)->clearInbox();
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
 }
开发者ID:stephenharris,项目名称:WordPressBehatExtension,代码行数:31,代码来源:WordPressContext.php

示例15: iShouldSeeDisplayWithFollowingFields

 /**
  * @Given /^I should see display with following fields$/
  */
 public function iShouldSeeDisplayWithFollowingFields(TableNode $table)
 {
     $display = $this->getPage('News display')->getElement('Display');
     foreach ($table->getHash() as $row) {
         expect($display->hasFieldWithName($row['Field name']))->toBe(true);
     }
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:10,代码来源:DisplayContext.php


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