mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Sitemaps: Rename 'sitemap' to 'provider' in WP_Sitemaps_Registry class.
This class is for registering sitemap providers, not individual sitemaps. Props swissspidy. Fixes #50724. git-svn-id: https://develop.svn.wordpress.org/trunk@48536 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -13,8 +13,8 @@ class Test_WP_Sitemaps_Index extends WP_UnitTestCase {
|
||||
* There are 2 providers registered.
|
||||
* Hence, 3*4*2=24.
|
||||
*/
|
||||
$registry->add_sitemap( 'foo', new WP_Sitemaps_Test_Provider( 'foo' ) );
|
||||
$registry->add_sitemap( 'bar', new WP_Sitemaps_Test_Provider( 'bar' ) );
|
||||
$registry->add_provider( 'foo', new WP_Sitemaps_Test_Provider( 'foo' ) );
|
||||
$registry->add_provider( 'bar', new WP_Sitemaps_Test_Provider( 'bar' ) );
|
||||
|
||||
$sitemap_index = new WP_Sitemaps_Index( $registry );
|
||||
$this->assertCount( 24, $sitemap_index->get_sitemap_list() );
|
||||
@@ -29,12 +29,12 @@ class Test_WP_Sitemaps_Index extends WP_UnitTestCase {
|
||||
$registry = new WP_Sitemaps_Registry();
|
||||
|
||||
// add 3 providers, which combined produce more than the maximum 50000 sitemaps in the index.
|
||||
$registry->add_sitemap( 'provider_1', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
$registry->add_sitemap( 'provider_2', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
$registry->add_sitemap( 'provider_3', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
$registry->add_provider( 'provider_1', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
$registry->add_provider( 'provider_2', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
$registry->add_provider( 'provider_3', new WP_Sitemaps_Large_Test_Provider( 25000 ) );
|
||||
|
||||
$count = 0;
|
||||
foreach ( $registry->get_sitemaps() as $provider ) {
|
||||
foreach ( $registry->get_providers() as $provider ) {
|
||||
$count += count( $provider->get_url_list( 1 ) );
|
||||
}
|
||||
$this->assertGreaterThan( 50000, $count );
|
||||
@@ -46,7 +46,7 @@ class Test_WP_Sitemaps_Index extends WP_UnitTestCase {
|
||||
public function test_get_sitemap_list_no_entries() {
|
||||
$registry = new WP_Sitemaps_Registry();
|
||||
|
||||
$registry->add_sitemap( 'foo', new WP_Sitemaps_Empty_Test_Provider( 'foo' ) );
|
||||
$registry->add_provider( 'foo', new WP_Sitemaps_Empty_Test_Provider( 'foo' ) );
|
||||
|
||||
$sitemap_index = new WP_Sitemaps_Index( $registry );
|
||||
$this->assertCount( 0, $sitemap_index->get_sitemap_list() );
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
* @group sitemaps
|
||||
*/
|
||||
class Test_WP_Sitemaps_Registry extends WP_UnitTestCase {
|
||||
public function test_add_sitemap() {
|
||||
public function test_add_provider() {
|
||||
$provider = new WP_Sitemaps_Test_Provider();
|
||||
$registry = new WP_Sitemaps_Registry();
|
||||
|
||||
$actual = $registry->add_sitemap( 'foo', $provider );
|
||||
$sitemaps = $registry->get_sitemaps();
|
||||
$actual = $registry->add_provider( 'foo', $provider );
|
||||
$sitemaps = $registry->get_providers();
|
||||
|
||||
$this->assertTrue( $actual );
|
||||
$this->assertCount( 1, $sitemaps );
|
||||
$this->assertSame( $sitemaps['foo'], $provider, 'Can not confirm sitemap registration is working.' );
|
||||
}
|
||||
|
||||
public function test_add_sitemap_prevent_duplicates() {
|
||||
public function test_add_provider_prevent_duplicates() {
|
||||
$provider1 = new WP_Sitemaps_Test_Provider();
|
||||
$provider2 = new WP_Sitemaps_Test_Provider();
|
||||
$registry = new WP_Sitemaps_Registry();
|
||||
|
||||
$actual1 = $registry->add_sitemap( 'foo', $provider1 );
|
||||
$actual2 = $registry->add_sitemap( 'foo', $provider2 );
|
||||
$sitemaps = $registry->get_sitemaps();
|
||||
$actual1 = $registry->add_provider( 'foo', $provider1 );
|
||||
$actual2 = $registry->add_provider( 'foo', $provider2 );
|
||||
$sitemaps = $registry->get_providers();
|
||||
|
||||
$this->assertTrue( $actual1 );
|
||||
$this->assertFalse( $actual2 );
|
||||
|
||||
Reference in New Issue
Block a user