<commit_before><?php
/**
 * Class Google\Site_Kit\Tests\Modules\SettingsTestCase
 *
 * @package   Google\Site_Kit\Tests\Modules
 * @copyright 2019 Google LLC
 * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
 * @link      https://sitekit.withgoogle.com
 */

namespace Google\Site_Kit\Tests\Modules;

use Google\Site_Kit\Tests\TestCase;

abstract class SettingsTestCase extends TestCase {

	/**
	 * @return string
	 */
	abstract protected function get_option_name();

	public function setUp() {
		parent::setUp();

		$option_name = $this->get_option_name();

		// Unregister setup that occurred during bootstrap.
		unregister_setting( $option_name, $option_name );

		remove_all_filters( "option_$option_name" );
		remove_all_filters( "site_option_$option_name" );
		remove_all_filters( "default_option_$option_name" );
		remove_all_filters( "default_site_option_$option_name" );

		delete_option( $option_name );
		delete_site_option( $option_name );
	}<commit_msg>Fix potential undefined index in SettingsTestCase.<commit_after><?php
/**
 * Class Google\Site_Kit\Tests\Modules\SettingsTestCase
 *
 * @package   Google\Site_Kit\Tests\Modules
 * @copyright 2019 Google LLC
 * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
 * @link      https://sitekit.withgoogle.com
 */

namespace Google\Site_Kit\Tests\Modules;

use Google\Site_Kit\Tests\TestCase;

abstract class SettingsTestCase extends TestCase {

	/**
	 * @return string
	 */
	abstract protected function get_option_name();

	public function setUp() {
		global $new_whitelist_options;
		parent::setUp();

		$option_name = $this->get_option_name();

		// Unregister setup that occurred during bootstrap.
		if ( array_key_exists( $option_name, $new_whitelist_options ) ) {
			unregister_setting( $option_name, $option_name );
		}

		remove_all_filters( "option_$option_name" );
		remove_all_filters( "site_option_$option_name" );
		remove_all_filters( "default_option_$option_name" );
		remove_all_filters( "default_site_option_$option_name" );

		delete_option( $option_name );
		delete_site_option( $option_name );
	}
{'fraction_non_alphanumeric': 0.11753643629525153, 'fraction_numerical': 0.007522331922896097, 'mean_word_length': 4.927576601671309, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2363150', 'n_tokens_mistral': 716, 'n_tokens_neox': 672, 'n_words': 127}