Files
wordpress-develop/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php
Sergey Biryukov 7f828b6b00 Tests: Rename classes in phpunit/tests/sitemaps/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51492 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-26 19:09:41 +00:00

35 lines
1.1 KiB
PHP

<?php
/**
* @group sitemaps
*/
class Tests_Sitemaps_wpSitemapsRegistry extends WP_UnitTestCase {
public function test_add_provider() {
$provider = new WP_Sitemaps_Test_Provider();
$registry = new WP_Sitemaps_Registry();
$actual = $registry->add_provider( 'foo', $provider );
$providers = $registry->get_providers();
$this->assertTrue( $actual );
$this->assertCount( 1, $providers );
$this->assertSame( $providers['foo'], $provider, 'Can not confirm sitemap registration is working.' );
}
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_provider( 'foo', $provider1 );
$actual2 = $registry->add_provider( 'foo', $provider2 );
$providers = $registry->get_providers();
$this->assertTrue( $actual1 );
$this->assertFalse( $actual2 );
$this->assertCount( 1, $providers );
$this->assertSame( $providers['foo'], $provider1, 'Can not confirm sitemap registration is working.' );
}
}