2023-05-22 13:43:10 -04:00
|
|
|
<?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' ),
|
|
|
|
|
]
|
|
|
|
|
),
|
2024-07-09 14:56:52 -04:00
|
|
|
$this->expectedField( 'updateSession.customer.id', $this->toRelayId( 'user', $registered ) ),
|
2023-05-22 13:43:10 -04:00
|
|
|
$this->expectedObject(
|
|
|
|
|
'updateSession.customer.session.#',
|
|
|
|
|
[
|
|
|
|
|
$this->expectedField( 'key', 'test-2' ),
|
|
|
|
|
$this->expectedField( 'value', 'test-value' ),
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$this->assertQuerySuccessful( $response, $expected );
|
|
|
|
|
}
|
|
|
|
|
}
|