Files
wp-graphql-woocommerce/tests/wpunit/UpdateSessionMutationTest.php
T
Geoffrey K TaylorandGitHub ba13b2ec0a feat: Authorizing URLs implemented and tested. (#745)
* feat: Authorizing URLs implemented and tested.

* feat: More woographql_*_nonce functions implemented.

* chore: linting changes made.

* chore: linting changes made.

* fix: woographql_*_ functions tested.

* chore: WPCS compliance met.

* devops: lint-code script updated to PHP v8.0

* chore: WPCS compliance met

* devops: TransferSessionHandlerTest & QLSessionHandlerTest updated

* devops: codeclimate.yml added.

* chore: Linter compliance met

* devops: Harmonizing WordPress doc written and Settings doc updated.

* chore: Typo fixed in docs.

* fix: General bugfixes and improvements related to Auth URLs

* devops: More docs.

* chore: Linter compliance met

* chore: small change made to docs.
2023-05-22 13:43:10 -04:00

67 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 );
}
}