本文整理汇总了PHP中Behat\Gherkin\Node\TableNode::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP TableNode::getTable方法的具体用法?PHP TableNode::getTable怎么用?PHP TableNode::getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Gherkin\Node\TableNode
的用法示例。
在下文中一共展示了TableNode::getTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ensureContentTypeGroupsExists
/**
* @Given there are the following Content Type Groups:
*
* Make sure that content type groups in the provided table exist, by identifier. Example:
* | group |
* | testContentTypeGroup1 |
* | testContentTypeGroup2 |
* | testContentTypeGroup3 |
*/
public function ensureContentTypeGroupsExists(TableNode $table)
{
$contentTypeGroups = $table->getTable();
array_shift($contentTypeGroups);
foreach ($contentTypeGroups as $contentTypeGroup) {
$this->ensureContentTypeGroupExists($contentTypeGroup[0]);
}
}
示例2: truncatedTables
/**
* @Given /^Truncated tables$/
* @param TableNode $table
*/
public function truncatedTables(TableNode $table)
{
foreach ($table->getTable() as $tableNames) {
foreach ($tableNames as $tableName) {
$this->clearTable($tableName);
}
}
}
示例3: iCallTheOperation
/**
* @When I call the :operation operation
* @When I call the :operation operation with
*/
public function iCallTheOperation($operation, TableNode $table = null)
{
$this->result = null;
$args = [];
if ($table) {
foreach ($table->getTable() as $row) {
$args[$row[0]] = $row[1];
}
}
$this->result = call_user_func([$this->sdk, $operation], $args);
}
示例4: transformTableNode
/**
* @param TableNode $table
* @return TableNode
*/
protected function transformTableNode(TableNode $table)
{
$tempList = $table->getTable();
foreach ($tempList as $key => $row) {
foreach ($row as $columnKey => $column) {
$newValue = $this->transformValue($column);
$tempList[$key][$columnKey] = $newValue;
}
}
return new TableNode($tempList);
}
示例5: iCallTheOperation
/**
* @When I call the :operation operation
* @When I call the :operation operation with
*/
public function iCallTheOperation($operation, TableNode $table = null)
{
$this->result = null;
$args = [];
if ($table) {
foreach ($table->getTable() as $row) {
if (isset($query)) {
$query .= "&";
} else {
$query = '';
}
$query .= $row[0] . '=' . $row[1];
}
if ($query) {
parse_str($query, $args);
}
}
try {
$this->result = call_user_func([$this->sdk, $operation], $args);
} catch (CommandClientException $e) {
$this->exception = $e;
}
}
示例6: applicationExists
/**
* @Then I should have the application
*/
public function applicationExists(TableNode $table)
{
/** @var ApplicationManager $applicationManager */
$applicationManager = self::$application->getServiceManager()->get('application/application-manager');
$data = [];
foreach ($table->getTable() as $row) {
$data[$row[0]] = $row[1];
}
$application = $applicationManager->get($data['name']);
\PHPUnit_Framework_Assert::assertInstanceOf('Continuous\\DeployAgent\\Application\\Application', $application);
foreach ($data as $property => $value) {
switch ($property) {
case 'pipeline':
$property = 'reference';
case 'token':
case 'repositoryProvider':
case 'repository':
\PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application->getProvider());
break;
case 'provider':
$provider = self::$application->getServiceManager()->get('provider/' . $value);
\PHPUnit_Framework_Assert::assertAttributeInstanceOf(get_class($provider), $property, $application);
break;
default:
\PHPUnit_Framework_Assert::assertAttributeEquals($value, $property, $application);
}
}
}
示例7: theFollowingHeadersShouldBeSet
/**
* @Then The following headers should be set
* @param \Behat\Gherkin\Node\TableNode $table
* @throws \Exception
*/
public function theFollowingHeadersShouldBeSet(\Behat\Gherkin\Node\TableNode $table)
{
foreach ($table->getTable() as $header) {
$headerName = $header[0];
$expectedHeaderValue = $header[1];
$returnedHeader = $this->response->getHeader($headerName);
if ($returnedHeader !== $expectedHeaderValue) {
throw new \Exception(sprintf("Expected value '%s' for header '%s', got '%s'", $expectedHeaderValue, $headerName, $returnedHeader));
}
}
}
示例8: assertUserWithNameExistsWithFields
/**
* @Then User with name :username has the following fields:
* @Then User with name :username exists with the following fields:
*
* Checks that user ':username' exists with the values provided in the field/value table. example:
* | Name | value |
* | email | testuser@ez.no |
* | password | testuser |
* | first_name | Test |
* | last_name | User |
*/
public function assertUserWithNameExistsWithFields($username, TableNode $table)
{
Assertion::assertTrue($this->checkUserExistenceByUsername($username), "Couldn't find User with name '{$username}'.");
$user = $this->userService->loadUserByLogin($username);
$fieldsTable = $table->getTable();
array_shift($fieldsTable);
$updateFields = array();
foreach ($fieldsTable as $fieldRow) {
$fieldName = $fieldRow[0];
$expectedValue = $fieldRow[1];
switch ($fieldName) {
case 'email':
$fieldValue = $user->email;
break;
case 'password':
$fieldValue = $user->passwordHash;
$expectedValue = $this->createPasswordHash($username, $expectedValue, $user->hashAlgorithm);
break;
default:
$fieldValue = $user->getFieldValue($fieldName);
}
Assertion::assertEquals($expectedValue, $fieldValue, "Field '{$fieldName}' did not contain expected value '{$expectedValue}'.");
}
}
示例9: theOrderTotalsShouldBeAsFollows
/**
* @Then The order totals should be as follows
*/
public function theOrderTotalsShouldBeAsFollows(TableNode $table)
{
$orderTotals = $this->_getOrderTotals();
$data = $table->getTable();
foreach ($data as $expectedTotals) {
if (count($expectedTotals) !== 2) {
throw new \Exception('Malformed table. Each row should have two columns');
}
$expectedValue = array_pop($expectedTotals);
$expectedKey = array_pop($expectedTotals);
if (!isset($orderTotals[$expectedKey])) {
throw new \Exception("Expected to find a total of {$expectedKey} but this was not found on the page");
}
if ($orderTotals[$expectedKey] !== $expectedValue) {
throw new \Exception("Expected {$expectedKey} to have a value of {$expectedValue}, found {$orderTotals[$expectedKey]}");
}
}
}
示例10: iHaveTheFollowingUserGroups
/**
* @Given there are the following User Groups:
*
* Make sure that user groups in the provided table exist in their respective parent group. Example:
* | childGroup | parentGroup |
* | testUserGroup1 | Members | # should create.
* | testUserGroup1 | Editors | # should create.
* | testUserGroup3 | Test Parent | # parent and child should be created.
* | innerGroup3-1 | testUserGroup3 | # should be created inside previous.
*/
public function iHaveTheFollowingUserGroups(TableNode $table)
{
$userGroups = $table->getTable();
array_shift($userGroups);
foreach ($userGroups as $userGroup) {
$this->getUserGroupManager()->ensureUserGroupExists($userGroup[0], $userGroup[1]);
}
}
示例11: testGetTable
public function testGetTable()
{
$table = new TableNode($a = array(5 => array('username', 'password'), 10 => array('everzet', 'qwerty'), 13 => array('antono', 'pa$sword')));
$this->assertEquals($a, $table->getTable());
}
示例12: transformRowTable
/**
* Helper method to transform column names in row tables.
*
* @param \Behat\Gherkin\Node\TableNode $table_node
* The table to transform.
* @param array $aliases
* An associative array of aliases that are uses for the column names. Keyed
* by alias, and with the transformed string as value.
*
* @return \Behat\Gherkin\Node\TableNode
* The transformed table
*
* @see self::transformArticleNodeTable()
*/
protected function transformRowTable(TableNode $table_node, array $aliases)
{
$table = $table_node->getTable();
array_walk($table, function (&$row) use($aliases) {
// The first column of the row contains the field names. Replace the
// aliased field name with the machine name if it exists.
if (array_key_exists($row[0], $aliases)) {
$row[0] = $aliases[$row[0]];
}
});
return new TableNode($table);
}
示例13: transformPostContentTable
/**
* Transforms human readable field names into machine names.
*
* This is used in field_handlers.feature for testing if human readable names
* can be used instead of machine names in tests.
*
* @param TableNode $post_table
* The original table.
*
* @return TableNode
* The transformed table.
*
* @Transform rowtable:title,body,reference,date,links,select,address
*/
public function transformPostContentTable(TableNode $post_table)
{
$aliases = array('reference' => 'field_post_reference', 'date' => 'field_post_date', 'links' => 'field_post_links', 'select' => 'field_post_select', 'address' => 'field_post_address');
$table = $post_table->getTable();
array_walk($table, function (&$row) use($aliases) {
// The first column of the row contains the field names. Replace the
// human readable field name with the machine name if it exists.
if (array_key_exists($row[0], $aliases)) {
$row[0] = $aliases[$row[0]];
}
});
return new TableNode($table);
}
示例14: castUsersTable
/**
* Transforms long address field columns into shorter aliases.
*
* This is used in field_handlers.feature for testing if lengthy field:column
* combinations can be shortened to more human friendly aliases.
*
* @Transform table:name,mail,street,city,postcode,country
*/
public function castUsersTable(TableNode $user_table)
{
$aliases = ['country' => 'field_post_address:country', 'city' => 'field_post_address:locality', 'street' => 'field_post_address:thoroughfare', 'postcode' => 'field_post_address:postal_code'];
// The first row of the table contains the field names.
$table = $user_table->getTable();
reset($table);
$first_row = key($table);
// Replace the aliased field names with the actual ones.
foreach ($table[$first_row] as $key => $alias) {
if (array_key_exists($alias, $aliases)) {
$table[$first_row][$key] = $aliases[$alias];
}
}
return new TableNode($table);
}
示例15: breadcrumbHasTheFollowingLinks
/**
* Tests if a link is present in the breadcrumbs.
* @Then the breadcrumb has the following links:
*/
public function breadcrumbHasTheFollowingLinks(TableNode $table)
{
foreach ($table->getTable() as $breadcrumbItem) {
$text = $breadcrumbItem[0];
$url = $breadcrumbItem[1];
// this is not a link (the current page)
if ($url === 'null') {
$query = sprintf('//ul[@id="wo-breadcrumbs"]/li/span[text()="%s"]', $text);
} else {
$query = sprintf('//ul[@id="wo-breadcrumbs"]/li/a[@href="%s"]/span[text()="%s"]', $url, $text);
}
Assertion::assertCount(1, $this->getXpath()->findXpath($query));
}
}