Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against infinite recursion error when validating AMP pages usin…
…g a Reader theme (#5410) Co-authored-by: Alain Schlesser <alain.schlesser@gmail.com>
- Loading branch information
1 parent
b9d9d30
commit 307028c
Showing
24 changed files
with
357 additions
and
113 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace AmpProject\AmpWP\Tests; | ||
|
||
use AmpProject\AmpWP\AmpWpPlugin; | ||
use AmpProject\AmpWP\Infrastructure\Injector; | ||
use AmpProject\AmpWP\Infrastructure\ServiceContainer; | ||
use AmpProject\AmpWP\Services; | ||
use AmpProject\AmpWP\Tests\Helpers\PrivateAccess; | ||
use WP_UnitTestCase; | ||
|
||
abstract class DependencyInjectedTestCase extends WP_UnitTestCase { | ||
|
||
use PrivateAccess; | ||
|
||
/** | ||
* Plugin instance to test with. | ||
* | ||
* @var AmpWpPlugin | ||
*/ | ||
protected $plugin; | ||
|
||
/** | ||
* Service container instance to test with. | ||
* | ||
* @var ServiceContainer | ||
*/ | ||
protected $container; | ||
|
||
/** | ||
* Injector instance to test with. | ||
* | ||
* @var Injector | ||
*/ | ||
protected $injector; | ||
|
||
/** | ||
* Set up the service architecture before each test run. | ||
*/ | ||
public function setUp() { | ||
parent::setUp(); | ||
|
||
// We're intentionally avoiding the AmpWpPluginFactory here as it uses a | ||
// static instance, because its whole point is to allow reuse across consumers. | ||
$this->plugin = new AmpWpPlugin(); | ||
$this->plugin->register(); | ||
|
||
$this->container = $this->plugin->get_container(); | ||
$this->injector = $this->container->get( 'injector' ); | ||
|
||
// The static Services helper has to be modified to use the same objects | ||
// as the ones that are injected into the tests. | ||
$this->set_private_property( Services::class, 'plugin', $this->plugin ); | ||
$this->set_private_property( Services::class, 'container', $this->container ); | ||
$this->set_private_property( Services::class, 'injector', $this->injector ); | ||
} | ||
|
||
/** | ||
* Clean up again after each test run. | ||
*/ | ||
public function tearDown() { | ||
parent::tearDown(); | ||
|
||
$this->set_private_property( Services::class, 'plugin', null ); | ||
$this->set_private_property( Services::class, 'container', null ); | ||
$this->set_private_property( Services::class, 'injector', null ); | ||
} | ||
} |
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
Oops, something went wrong.