-
Notifications
You must be signed in to change notification settings - Fork 243
Closes #8451 Show Rocket Insights CDN recommendation based on RocketCDN subscription state #8646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Khadreal
wants to merge
8
commits into
develop
Choose a base branch
from
enhancement/8451-rocket-recommendation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f1d6f2
Modify logic to cater for different scenario for rocket insight :clos…
Khadreal 94a54cc
Merge branch 'develop' into enhancement/8451-rocket-recommendation
hanna-meda 1be6fa5
review modifications
Khadreal 39f830b
Add check for reseller account
Khadreal 0a018ad
Update test
Khadreal 67ba9fb
Modify logic and update button copy
Khadreal 2333ca8
Merge branch 'develop' into enhancement/8451-rocket-recommendation
hellofromahmed 159c03a
Merge branch 'develop' into enhancement/8451-rocket-recommendation
Mai-Saad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
.../Engine/CDN/RocketCDN/AdminPageSubscriber/maybeAddRocketcdnToRecommendationsApiParams.php
This file contains hidden or 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,89 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| namespace WP_Rocket\Tests\Unit\inc\Engine\CDN\RocketCDN\AdminPageSubscriber; | ||
|
|
||
| use Mockery; | ||
| use WP_Rocket\Engine\CDN\RocketCDN\AdminPageSubscriber; | ||
| use WP_Rocket\Engine\CDN\RocketCDN\APIClient; | ||
| use WP_Rocket\Engine\License\API\User; | ||
| use WP_Rocket\Engine\License\API\UserClient; | ||
| use WP_Rocket\Tests\Unit\TestCase; | ||
|
|
||
| /** | ||
| * Test class covering \WP_Rocket\Engine\CDN\RocketCDN\AdminPageSubscriber::maybe_add_rocketcdn_to_recommendations_api_params | ||
| * | ||
| * @covers \WP_Rocket\Engine\CDN\RocketCDN\AdminPageSubscriber::maybe_add_rocketcdn_to_recommendations_api_params | ||
| * @group RocketCDN | ||
| * @group RocketCDNAdminPage | ||
| */ | ||
| class Test_MaybeAddRocketcdnToRecommendationsApiParams extends TestCase { | ||
|
|
||
| /** | ||
| * @var Mockery\MockInterface|APIClient | ||
| */ | ||
| private $api_client; | ||
|
|
||
| /** | ||
| * @var Mockery\MockInterface|UserClient | ||
| */ | ||
| private $user_client; | ||
|
|
||
| /** | ||
| * @var Mockery\MockInterface|User | ||
| */ | ||
| private $user; | ||
|
|
||
| /** | ||
| * @var AdminPageSubscriber | ||
| */ | ||
| private $subscriber; | ||
|
|
||
| public function set_up(): void { | ||
| parent::set_up(); | ||
|
|
||
| $this->constants['ROCKETCDN_VERSION'] = ''; | ||
|
|
||
| $this->api_client = Mockery::mock( APIClient::class ); | ||
| $this->user_client = Mockery::mock( UserClient::class ); | ||
| $this->user = Mockery::mock( User::class ); | ||
| $this->user->shouldReceive( 'is_reseller_account' )->andReturn( false )->byDefault(); | ||
|
|
||
| $this->subscriber = new AdminPageSubscriber( | ||
| $this->api_client, | ||
| $this->user_client, | ||
| $this->user, | ||
| '' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @dataProvider configTestData | ||
| */ | ||
| public function testShouldModifyParamsCorrectly( $config, $expected ): void { | ||
| $this->white_label = $config['white_label'] ?? false; | ||
|
|
||
| if ( $config['is_reseller'] ?? false ) { | ||
| $this->user->shouldReceive( 'is_reseller_account' )->andReturn( true ); | ||
| } | ||
|
|
||
| $cdn_in_options = in_array( 'cdn', $config['params']['enabled_options'] ?? [], true ); | ||
|
|
||
| if ( $this->white_label || $cdn_in_options ) { | ||
| $subscription_data = [ | ||
| 'subscription_status' => $config['subscription_status'] ?? '', | ||
| 'plan_type' => $config['plan_type'] ?? '', | ||
| ]; | ||
|
|
||
| $this->api_client->shouldReceive( 'get_subscription_data' ) | ||
| ->once() | ||
| ->andReturn( $subscription_data ); | ||
| } else { | ||
| $this->api_client->shouldNotReceive( 'get_subscription_data' ); | ||
| } | ||
|
|
||
| $result = $this->subscriber->maybe_add_rocketcdn_to_recommendations_api_params( $config['params'] ); | ||
|
|
||
| $this->assertSame( $expected['params'], $result ); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.