-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy
dotenv-flow
changes to Prod (#654)
* fix: correct domain replacement for graphql fields (#650) * docs: correct `dotenv` dep to `dotenv-flow` (#646) * docs: correct `dotenv` dep to `dotenv-flow` * docs: replace rest of `dotenv` -> `dotenv-flow` Co-authored-by: Andrew Matthews <[email protected]>
- Loading branch information
1 parent
e3f68d1
commit 7e46646
Showing
5 changed files
with
162 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
plugins/faustwp/tests/integration/replacement/test-graphql-callbacks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
/** | ||
* Class GraphQLCallbacksTestCases | ||
* | ||
* @package FaustWP | ||
*/ | ||
|
||
namespace WPE\FaustWP\Tests\Replacement; | ||
|
||
use function WPE\FaustWP\Replacement\{ url_replacement }; | ||
use function WPE\FaustWP\Settings\faustwp_update_setting; | ||
|
||
class GraphQLCallbacksTestCases extends \WP_UnitTestCase { | ||
|
||
private $graphqlResponse; | ||
|
||
private $responseData = [ | ||
'generalSettings' => [ | ||
'url' => 'http://example.org' | ||
], | ||
'menuItems' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => 'Hello World', | ||
'url' => 'http://example.org/hello-world/' | ||
], | ||
[ | ||
'label' => 'External Site', | ||
'url' => 'http://external.site/no-replacement' | ||
] | ||
] | ||
], | ||
'menus' => [ | ||
'nodes' => [ | ||
[ | ||
'menuItems' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => 'Hello World', | ||
'url' => 'http://example.org/hello-world/' | ||
] | ||
] | ||
] | ||
] | ||
] | ||
], | ||
'aThingWithHref' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => "This uses href instead of url fields", | ||
'href' => 'http://example.org/href' | ||
] | ||
] | ||
] | ||
]; | ||
|
||
private $expectedData = [ | ||
'generalSettings' => [ | ||
'url' => 'http://example.org' | ||
], | ||
'menuItems' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => 'Hello World', | ||
'url' => 'http://frontend/hello-world/' | ||
], | ||
[ | ||
'label' => 'External Site', | ||
'url' => 'http://external.site/no-replacement' | ||
] | ||
] | ||
], | ||
'menus' => [ | ||
'nodes' => [ | ||
[ | ||
'menuItems' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => 'Hello World', | ||
'url' => 'http://frontend/hello-world/' | ||
] | ||
] | ||
] | ||
] | ||
] | ||
], | ||
'aThingWithHref' => [ | ||
'nodes' => [ | ||
[ | ||
'label' => "This uses href instead of url fields", | ||
'href' => 'http://frontend/href' | ||
] | ||
] | ||
] | ||
]; | ||
|
||
public function setUp() { | ||
parent::setUp(); | ||
|
||
faustwp_update_setting( 'frontend_uri', 'http://frontend' ); | ||
|
||
$this->graphqlResponse = new \stdClass(); | ||
$this->graphqlResponse->data = $this->responseData; | ||
} | ||
|
||
public function test_graphql_request_results_filter() { | ||
$this->assertSame( 10, has_action( 'graphql_request_results', 'WPE\FaustWP\Replacement\url_replacement' ) ); | ||
} | ||
|
||
/** | ||
* Tests url_replacement() returns original data when rewrites are not enabled. | ||
*/ | ||
public function test_url_replacement_does_not_alter_response_when_rewrites_are_not_enabled() { | ||
faustwp_update_setting( 'enable_rewrites', '0' ); | ||
$filteredRespone = url_replacement( $this->graphqlResponse ); | ||
$this->assertSame( $this->responseData, $filteredRespone->data ); | ||
} | ||
|
||
/** | ||
* Tests url_replacement() does not modify generalSettings even when rewrites are enabled. | ||
*/ | ||
public function test_url_replacement_does_not_alter_generalSettings_when_rewrites_are_enabled() { | ||
faustwp_update_setting( 'enable_rewrites', '1' ); | ||
$filteredRespone = url_replacement( $this->graphqlResponse ); | ||
$this->assertSame( $this->responseData['generalSettings'], $filteredRespone->data['generalSettings'] ); | ||
} | ||
|
||
/** | ||
* Tests url_replacement() modifies url and href fields when rewrites are enabled. | ||
*/ | ||
public function test_url_replacement_replaces_url_fields_when_rewrites_are_enabled() { | ||
faustwp_update_setting( 'enable_rewrites', '1' ); | ||
$filteredRespone = url_replacement( $this->graphqlResponse ); | ||
$this->assertSame( $this->expectedData, $filteredRespone->data ); | ||
} | ||
} |
7e46646
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch main was deployed successfully
Your environment Production of app faustjs-site was successfully updated
View build logs: https://my.wpengine.com/atlas#/faustjs-site/cwa4v7z4d1u9vi7qw7hythg2/ktcyquuf386lfxnhme9c0wr3
View your environment URL: https://faustjs.org