mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
* 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
66 lines
1.6 KiB
PHP
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 );
|
|
}
|
|
}
|