Files
wp-graphql-woocommerce/tests/wpunit/UpdateSessionMutationTest.php
T
Dovid LevineandGitHub e96236696f chore: bump deps to meet actual requirements and lint for WPCS 3.0 (#816)
* chore: bump min versions to actual and update deps

* chore: fix multiple empty lines at EOF

* chore: preincrement when standalone (phpcs)

* fix: use `printf` instead of `echo sprintf` [phpcs]

* chore: avoid lonely `if()` in `else{}` [phpcs]

* chore: avoid reserved keywords as param names [phpcs]

* chore: remove unused callback params [phpcs]

* chore: remove more unused callback params [phpcs]

* chore: apply lints to tests

* chore: update ruleset for PHPCS 3.0

* texts: restore $last_request_headers
2023-11-30 08:41:32 -05:00

66 lines
1.6 KiB
PHP

<?php
class UpdateSessionMutationTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGraphQLTestCase {
public function testUpdateSessionMutation() {
// Create registered customer.
$registered = $this->factory->customer->create();
$this->loginAs( $registered );
// Create query.
$query = '
mutation($input: UpdateSessionInput!) {
updateSession(input: $input) {
session {
id
key
value
}
customer {
id
session {
id
key
value
}
}
}
}
';
$variables = [
'input' => [
'sessionData' => [
[
'key' => 'test-2',
'value' => 'test-value',
],
],
],
];
/**
* Assert working.
*/
$response = $this->graphql( compact( 'query', 'variables' ) );
$expected = [
$this->expectedObject(
'updateSession.session.#',
[
$this->expectedField( 'key', 'test-2' ),
$this->expectedField( 'value', 'test-value' ),
]
),
$this->expectedField( 'updateSession.customer.id', $this->toRelayId( 'customer', $registered ) ),
$this->expectedObject(
'updateSession.customer.session.#',
[
$this->expectedField( 'key', 'test-2' ),
$this->expectedField( 'value', 'test-value' ),
]
),
];
$this->assertQuerySuccessful( $response, $expected );
}
}