<commit_before><?php

namespace Isotop\Tests\Syncs;

use Isotop\Syncs\Syncs;

class Syncs_Test extends \WP_UnitTestCase {

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

		$this->syncs = Syncs::instance();
	}

	public static function wpSetUpBeforeClass( $factory ) {
		$factory->blog->create( [
			'domain' => 'example.org',
			'path'   => '/foo/'
		] );
	}

	public static function wpTearDownAfterClass() {
		wpmu_delete_blog( 2, true );
		wp_update_network_site_counts();
	}

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

		unset( $this->syncs );
	}

	public function test_save_post() {
		$post_id = $this->factory->post->create();
		$post    = get_post( $post_id );

		// Not a valid post type.
		$this->assertFalse( $this->syncs->save_post( $post_id, $post ) );

		add_filter( 'syncs_post_types', function () {
			return ['post'];
		} );

		$this->assertTrue( $this->syncs->save_post( $post_id, get_post( $post_id ) ) );

		switch_to_blog( 2 );

		$posts = get_posts();

		// But post title should match since it's the same post.
		$this->assertSame( $posts[0]->post_title, $post->post_title );

		restore_current_blog();
	}

	public function test_save_term() {
		$term_id = $this->factory->category->create();
		$term    = get_category( $term_id );

		// Not a valid taxonomy.
		$this->assertFalse( $this->syncs->save_term( $term_id, 0, 'category' ) );

		add_filter( 'syncs_taxonomies', function () {
			return ['category'];
		} );

		$this->assertTrue( $this->syncs->save_term( $term_id, 0, 'category' ) );

		switch_to_blog( 2 );

		$terms = get_categories( ['hide_empty' => false] );

		// But category name should match since it's the same category.
		$this->assertSame( $terms[0]->name, $term->name );

		restore_current_blog();
	}
}
<commit_msg>Test so we are on second site<commit_after><?php

namespace Isotop\Tests\Syncs;

use Isotop\Syncs\Syncs;

class Syncs_Test extends \WP_UnitTestCase {

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

		$this->syncs = Syncs::instance();
	}

	public static function wpSetUpBeforeClass( $factory ) {
		$factory->blog->create( [
			'domain' => 'example.org',
			'path'   => '/foo/'
		] );
	}

	public static function wpTearDownAfterClass() {
		wpmu_delete_blog( 2, true );
		wp_update_network_site_counts();
	}

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

		unset( $this->syncs );
	}

	public function test_save_post() {
		$post_id = $this->factory->post->create();
		$post    = get_post( $post_id );

		// Not a valid post type.
		$this->assertFalse( $this->syncs->save_post( $post_id, $post ) );

		add_filter( 'syncs_post_types', function () {
			return ['post'];
		} );

		$this->assertTrue( $this->syncs->save_post( $post_id, get_post( $post_id ) ) );

		switch_to_blog( 2 );

		$posts = get_posts();

		$this->assertSame( 2, get_current_blog_id() );

		// But post title should match since it's the same post.
		$this->assertSame( $posts[0]->post_title, $post->post_title );

		restore_current_blog();
	}

	public function test_save_term() {
		$term_id = $this->factory->category->create();
		$term    = get_category( $term_id );

		// Not a valid taxonomy.
		$this->assertFalse( $this->syncs->save_term( $term_id, 0, 'category' ) );

		add_filter( 'syncs_taxonomies', function () {
			return ['category'];
		} );

		$this->assertTrue( $this->syncs->save_term( $term_id, 0, 'category' ) );

		switch_to_blog( 2 );

		$terms = get_categories( ['hide_empty' => false] );

		$this->assertSame( 2, get_current_blog_id() );

		// But category name should match since it's the same category.
		$this->assertSame( $terms[0]->name, $term->name );

		restore_current_blog();
	}
}

{'fraction_non_alphanumeric': 0.17233809001097694, 'fraction_numerical': 0.0043907793633369925, 'mean_word_length': 3.93234100135318, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2092788', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1302, 'n_words': 274}