本文整理汇总了PHP中Behat\Gherkin\Node\TableNode::getHash方法的典型用法代码示例。如果您正苦于以下问题:PHP TableNode::getHash方法的具体用法?PHP TableNode::getHash怎么用?PHP TableNode::getHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Gherkin\Node\TableNode
的用法示例。
在下文中一共展示了TableNode::getHash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: iShouldSeeFollowingList
/**
* @Then /^I should see following list$/
*/
public function iShouldSeeFollowingList(TableNode $table)
{
/** @var \FSi\Bundle\AdminTranslatableBundle\Behat\Context\Page\Element\Grid $grid */
$grid = $this->getElement('Grid');
expect(count($table->getHash()))->toBe($grid->getRowsCount());
$rowNumber = 1;
foreach ($table->getHash() as $row) {
foreach ($row as $columnName => $cellValue) {
$cell = $grid->getCell($rowNumber, $grid->getColumnPosition($columnName));
expect($cell->getText())->toBe($cellValue);
}
$rowNumber++;
}
}
示例2: iShouldSeeInDatabase
/**
* @Then I should see in database:
*/
public function iShouldSeeInDatabase(TableNode $table)
{
$actual = $this->getConnection()->createQueryBuilder()->select('*')->from($this->workingTable)->execute()->fetchAll();
foreach ($table->getHash() as $key => $expected) {
PHPUnit_Framework_Assert::assertEquals($expected, $actual[$key]);
}
}
示例3: thereIsFollowingRoleHierarchy
/**
* @Given there is following role hierarchy:
*/
public function thereIsFollowingRoleHierarchy(TableNode $table)
{
$repository = $this->getRepository('role');
$manager = $this->getEntityManager();
foreach ($repository->findAll() as $existingRole) {
$manager->remove($existingRole);
}
$manager->flush();
$root = $repository->createNew();
$root->setCode('root');
$root->setName('Root');
$manager->persist($root);
$manager->flush();
$roles = array();
foreach ($table->getHash() as $data) {
$role = $repository->createNew();
$role->setCode($data['code']);
$role->setName($data['name']);
if (!empty($data['parent'])) {
$role->setParent($roles[trim($data['parent'])]);
} else {
$role->setParent($root);
}
if (!empty($data['security roles'])) {
$securityRoles = array();
foreach (explode(',', $data['security roles']) as $securityRole) {
$securityRoles[] = trim($securityRole);
}
$role->setSecurityRoles($securityRoles);
}
$roles[$data['code']] = $role;
$manager->persist($role);
}
$manager->flush();
}
示例4: iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt
/**
* @Then /^I should get the following products after apply the following updater to it:$/
*
* @param TableNode $updates
*
* @throws \Exception
*/
public function iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt(TableNode $updates)
{
$application = $this->getApplicationsForUpdaterProduct();
$updateCommand = $application->find('pim:product:update');
$updateCommand->setContainer($this->getMainContext()->getContainer());
$updateCommandTester = new CommandTester($updateCommand);
$getCommand = $application->find('pim:product:get');
$getCommand->setContainer($this->getMainContext()->getContainer());
$getCommandTester = new CommandTester($getCommand);
foreach ($updates->getHash() as $update) {
$username = isset($update['username']) ? $update['username'] : null;
$updateCommandTester->execute(['command' => $updateCommand->getName(), 'identifier' => $update['product'], 'json_updates' => $update['actions'], 'username' => $username]);
$expected = json_decode($update['result'], true);
if (isset($expected['product'])) {
$getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $expected['product']]);
unset($expected['product']);
} else {
$getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $update['product']]);
}
$actual = json_decode($getCommandTester->getDisplay(), true);
if (null === $actual) {
throw new \Exception(sprintf('An error occured during the execution of the update command : %s', $getCommandTester->getDisplay()));
}
if (null === $expected) {
throw new \Exception(sprintf('Looks like the expected result is not valid json : %s', $update['result']));
}
$diff = $this->arrayIntersect($actual, $expected);
assertEquals($expected, $diff);
}
}
示例5: usersExist
/**
* @Given /^Users exist:$/
*/
public function usersExist(TableNode $table)
{
$usersData = $table->getHash();
add_filter('send_password_change_email', '__return_false');
add_filter('send_email_change_email', '__return_false');
foreach ($usersData as $userData) {
if (empty($userData['login'])) {
throw new \InvalidArgumentException('You must provide a user login!');
}
$user = get_user_by('login', $userData['login']);
$data = $this->getUserDataFromTable($userData);
if ($user) {
$data['ID'] = $user->ID;
}
$result = $user ? wp_update_user($data) : wp_insert_user($data);
if (is_wp_error($result)) {
throw new \UnexpectedValueException('User could not be created: ' . $result->get_error_message());
}
foreach ($this->getUserMetaDataFromTable($userData) as $key => $value) {
update_user_meta($user->ID, $key, $value);
}
}
remove_filter('send_password_change_email', '__return_false');
remove_filter('send_email_change_email', '__return_false');
}
示例6: i_define_the_following_marking_guide
/**
* Defines the marking guide with the provided data, following marking guide's definition grid cells.
*
* This method fills the marking guide of the marking guide definition
* form; the provided TableNode should contain one row for
* each criterion and each cell of the row should contain:
* # Criterion name, a.k.a. shortname
* # Description for students
* # Description for markers
* # Max score
*
* Works with both JS and non-JS.
*
* @When /^I define the following marking guide:$/
* @throws ExpectationException
* @param TableNode $guide
*/
public function i_define_the_following_marking_guide(TableNode $guide)
{
$steptableinfo = '| Criterion name | Description for students | Description for markers | Maximum score |';
if ($criteria = $guide->getHash()) {
$addcriterionbutton = $this->find_button(get_string('addcriterion', 'gradingform_guide'));
foreach ($criteria as $index => $criterion) {
// Make sure the criterion array has 4 elements.
if (count($criterion) != 4) {
throw new ExpectationException('The criterion definition should contain name, description for students and markers, and maximum points. ' . 'Please follow this format: ' . $steptableinfo, $this->getSession());
}
// On load, there's already a criterion template ready.
$shortnamevisible = false;
if ($index > 0) {
// So if the index is greater than 0, we click the Add new criterion button to add a new criterion.
$addcriterionbutton->click();
$shortnamevisible = true;
}
$criterionroot = 'guide[criteria][NEWID' . ($index + 1) . ']';
// Set the field value for the Criterion name.
$this->set_guide_field_value($criterionroot . '[shortname]', $criterion['Criterion name'], $shortnamevisible);
// Set the field value for the Description for students field.
$this->set_guide_field_value($criterionroot . '[description]', $criterion['Description for students']);
// Set the field value for the Description for markers field.
$this->set_guide_field_value($criterionroot . '[descriptionmarkers]', $criterion['Description for markers']);
// Set the field value for the Max score field.
$this->set_guide_field_value($criterionroot . '[maxscore]', $criterion['Maximum score']);
}
}
}
示例7: 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);
}
}
示例8: postsExist
/**
* @Given Posts exist:
*/
public function postsExist(TableNode $table)
{
$postsData = $table->getHash();
foreach ($postsData as $postData) {
$this->processPost($postData);
}
}
示例9: thereArePublishedLeaderNews
/**
* @Given /^There are published representative news$/
*/
public function thereArePublishedLeaderNews(TableNode $table)
{
/* @var $em EntityManager */
$em = $this->getEm();
/* @var $activityService \Civix\CoreBundle\Service\ActivityUpdate */
$activityService = $this->getMainContext()->getContainer()->get('civix_core.activity_update');
$hash = $table->getHash();
$diffSec = 0;
foreach ($hash as $row) {
$diffSec++;
$news = new RepresentativeNews();
$news->setUser($em->getRepository(Representative::class)->findOneByUsername($row['username']));
$news->setSubject($row['subject']);
$news->setPublishedAt(new \DateTime());
$em->persist($news);
$em->flush($news);
$activity = $activityService->publishLeaderNewsToActivity($news);
$activity->getSentAt()->sub(new \DateInterval('PT' . (count($hash) - $diffSec) . 'S'));
$activity->setSentAt(clone $activity->getSentAt());
if (!empty($row['expired_interval_direction'])) {
$expired = new \DateTime();
$expired->{$row}['expired_interval_direction'](new \DateInterval($row['expired_interval_value']));
$activity->setExpireAt($expired);
$em->flush($activity);
}
}
$result = $em->getRepository(LeaderNewsActivity::class)->findAll();
Assert::assertTrue(count($result) >= count($hash));
}
示例10: thereAreFollowingGalleries
/**
* @Given /^there are following galleries$/
*/
public function thereAreFollowingGalleries(TableNode $galleries)
{
$generator = Factory::create();
$imagesDir = $this->createGalleryFixturesDir();
foreach ($galleries->getHash() as $galleryData) {
$photos = new ArrayCollection();
for ($i = 0; $i < (int) $galleryData['Photos count']; $i++) {
$image = $generator->image($imagesDir, 600, 400);
$imageFile = new UploadedFile($image, basename($image), null, null, null, true);
$photo = new Photo();
$photo->setPhoto($imageFile);
$this->getDoctrine()->getManager()->persist($photo);
$this->getDoctrine()->getManager()->flush();
$photos->add($photo);
}
$gallery = new Gallery();
$gallery->setName($galleryData['Name']);
$gallery->setDescription($galleryData['Description']);
$gallery->setVisible($galleryData['Visible'] === 'true');
$gallery->setPhotos($photos);
$this->getDoctrine()->getManager()->persist($gallery);
$this->getDoctrine()->getManager()->flush();
$this->getDoctrine()->getManager()->clear();
}
$this->removeFixtures($imagesDir);
}
示例11: iShouldHaveAStyleWithTheFollowingDataOnTheCell
/**
* @Then /^I should have a "([^"]*)" style with the following data on the cell with the coordinates "(\d+),(\d+)" in the sheet "(\d+)":$/
*/
public function iShouldHaveAStyleWithTheFollowingDataOnTheCell($style, $x, $y, $sheetIndex, TableNode $data)
{
$phpExcelStyle = $this->getMainContext()->excelOutput->getSheet($sheetIndex)->getStyleByColumnAndRow($x, $y);
switch ($style) {
case 'Alignment':
$style = $phpExcelStyle->getAlignment();
break;
case 'Fill':
$style = $phpExcelStyle->getFill();
break;
case 'Font':
$style = $phpExcelStyle->getFont();
break;
default:
throw new Exception("You must specify a following style : Font, Fill, Alignment, Format");
break;
}
foreach ($data->getHash()[0] as $property => $value) {
$method = 'get' . ucfirst($property);
if (method_exists($style, $method)) {
$rawValue = $style->{$method}();
if (is_object($rawValue)) {
Assert::assertEquals($value, $style->{$method}()->getRGB());
continue;
}
Assert::assertEquals($value, $style->{$method}());
}
}
}
示例12: thereAreTheFollowingUsers
/**
* @Given There are the following users
*/
public function thereAreTheFollowingUsers(TableNode $table)
{
#var_dump($table->getHash());echo "\n",__METHOD__,':',__LINE__,"\n";die;
foreach ($table->getHash() as $hash) {
#$this->createUser($hash);
}
}
示例13: assertProductTranslations
/**
* @Given I should have the following translations for product :product:
*/
public function assertProductTranslations(Product $product, TableNode $table)
{
foreach ($table->getHash() as $data) {
PHPUnit_Framework_Assert::assertSame($data['title'], $product->getTranslation($data['locale'])->getTitle());
PHPUnit_Framework_Assert::assertSame($data['description'], $product->getTranslation($data['locale'])->getDescription());
}
}
示例14: theFollowingPeopleExist
/**
* @Given The following people exist:
*/
public function theFollowingPeopleExist(TableNode $table)
{
$hash = $table->getHash();
foreach ($hash as $row) {
$this->users[$row['username']] = $this->createUser($row);
}
}
示例15: testHashTable
public function testHashTable()
{
$table = new TableNode(array(array('username', 'password'), array('everzet', 'qwerty'), array('antono', 'pa$sword')));
$this->assertEquals(array(array('username' => 'everzet', 'password' => 'qwerty'), array('username' => 'antono', 'password' => 'pa$sword')), $table->getHash());
$table = new TableNode(array(array('username', 'password'), array('', 'qwerty'), array('antono', ''), array('', '')));
$this->assertEquals(array(array('username' => '', 'password' => 'qwerty'), array('username' => 'antono', 'password' => ''), array('username' => '', 'password' => '')), $table->getHash());
}