Skip to content
wiki.fftac.org

Site Deployment Tests - Source Excerpt 02

Back to Site Deployment Tests

Summary

This source excerpt preserves a bounded section of Antichrist.net/wp-content/plugins/antichrist-content-system/tests/site-deployment-tests.php so readers can inspect the evidence without opening the full source file.

**Source path:** Antichrist.net/wp-content/plugins/antichrist-content-system/tests/site-deployment-tests.php

/**
 * Assert that a route resolves to a seeded page path.
 *
 * @param string $path Page path.
 * @param string $route Route path.
 * @return WP_Post
 */
function acn_site_test_assert_route_resolves_to_page( $path, $route ) {
	$expected = acn_site_test_public_route_path( $path );
	$stripped = acn_site_test_strip_locale_prefix( $route );

	acn_site_test_assert( $expected === $stripped, "{$route} stripped to {$stripped}, expected {$expected}." );

	$post = get_page_by_path( trim( $stripped, '/' ), OBJECT, 'page' );
	acn_site_test_assert( $post instanceof WP_Post, "{$route} resolved to missing page path {$stripped}." );
	acn_site_test_assert( 'publish' === $post->post_status, "{$route} resolved to {$post->post_status} page {$stripped}." );

	return $post;
}

/**
 * Assert a rendered public page has enough real content.
 *
 * @param string  $path Page path.
 * @param WP_Post $post Page post.
 */
function acn_site_test_assert_substantive_page_content( $path, $post ) {
	$text = acn_site_test_rendered_page_text( $post );
	acn_site_test_assert( strlen( $text ) >= 220, "{$path} public content is too thin." );
}

echo "SETUP configure locale router\n";
acn_cs_configure_locale_router();
echo "SETUP seed content system\n";
acn_cs_seed_content_system();
if ( function_exists( 'acn_reports_seed_expansion' ) ) {
	echo "SETUP seed report expansion\n";
	acn_reports_seed_expansion();
}
echo "SETUP rebuild menus\n";
acn_cs_rebuild_menus();
echo "SETUP write dictionaries\n";
acn_cs_write_ns12_dictionaries();
if ( function_exists( 'acnmb_seed_defaults' ) ) {
	echo "SETUP seed message board\n";
	acnmb_seed_defaults();
}
echo "SETUP flush rewrite rules\n";
flush_rewrite_rules( false );
echo "SETUP complete\n";

acn_site_test_case(
	'seeds the complete publication page catalog',
	function () {
		$pages = acn_site_test_expected_pages();
		acn_site_test_assert( count( $pages ) > 40, 'Expected the seeded catalog to contain the full topic/report set.' );

		foreach ( $pages as $path => $page ) {
			$expected_status = isset( $page['status'] ) ? (string) $page['status'] : 'publish';
			$post            = get_page_by_path( $path, OBJECT, 'page' );

			acn_site_test_assert( $post instanceof WP_Post, "{$path} page is missing." );
			acn_site_test_assert( $expected_status === $post->post_status, "{$path} status should be {$expected_status}, found {$post->post_status}." );
		}
	}
);

acn_site_test_case(
	'self-repairs a missing catalog page even when the installed version is current',
	function () {
		$path = 'apocalyptic-optimism';
		$page = get_page_by_path( $path, OBJECT, 'page' );
		acn_site_test_assert( $page instanceof WP_Post, "{$path} page must exist before repair test." );

		update_option( 'acn_content_system_version', ACN_CONTENT_SYSTEM_VERSION, false );
		wp_update_post(
			wp_slash(
				array(
					'ID'          => $page->ID,
					'post_status' => 'draft',
				)
			)
		);

		try {
			acn_cs_seed_content_system();
			$repaired = get_page_by_path( $path, OBJECT, 'page' );
			acn_site_test_assert( $repaired instanceof WP_Post, "{$path} was not recreated." );
			acn_site_test_assert( 'publish' === $repaired->post_status, "{$path} was not republished by self-repair." );
		} finally {
			acn_cs_seed_content_system();
		}
	}
);

acn_site_test_case(
	'self-repairs a published catalog page with empty content',
	function () {
		$path = 'current-antichrist-cults';
		$page = get_page_by_path( $path, OBJECT, 'page' );
		acn_site_test_assert( $page instanceof WP_Post, "{$path} page must exist before repair test." );

		update_option( 'acn_content_system_version', ACN_CONTENT_SYSTEM_VERSION, false );
		wp_update_post(
			wp_slash(
				array(
					'ID'           => $page->ID,
					'post_content' => '',
					'post_status'  => 'publish',
				)
			)
		);

		try {
			acn_cs_seed_content_system();
			$repaired = get_page_by_path( $path, OBJECT, 'page' );
			acn_site_test_assert( $repaired instanceof WP_Post, "{$path} was not repaired." );
			$text = acn_site_test_rendered_page_text( $repaired );
			acn_site_test_assert( strlen( $text ) > 5000, "{$path} content is still too thin after repair." );
			acn_site_test_assert( false !== strpos( $text, 'Core Ideas' ), "{$path} repaired content is missing the expected section body." );
			acn_site_test_assert( false !== strpos( $text, 'Research Dossier: Antichrist Cults and Antichrist Rhetoric' ), "{$path} repaired content is missing the packaged research dossier." );
			acn_site_test_assert( false !== strpos( $text, 'Order of Nine Angles' ), "{$path} repaired content is missing detailed case-study content." );
		} finally {
			acn_cs_seed_content_system();
		}
	}
);

acn_site_test_case(
	'keeps seeded public pages substantive and free of internal placeholders',
	function () {
		$forbidden = array(
			'No child pages are attached',
			'requested research dossier',
			'setup placeholder',
			'lorem' . ' ipsum',
			'seo.post.',
			'seo.page.',
		);

		foreach ( acn_site_test_expected_pages() as $path => $page ) {
			$expected_status = isset( $page['status'] ) ? (string) $page['status'] : 'publish';
			if ( 'publish' !== $expected_status ) {
				continue;
			}

			$post = get_page_by_path( $path, OBJECT, 'page' );
			acn_site_test_assert( $post instanceof WP_Post, "{$path} page is missing." );

			$text = acn_site_test_rendered_page_text( $post );
			acn_site_test_assert( strlen( $text ) >= 220, "{$path} public content is too thin." );

			foreach ( $forbidden as $needle ) {
				acn_site_test_assert( false === stripos( $text, $needle ), "{$path} exposes forbidden public text: {$needle}." );
			}

			if ( 'current-antichrist-cults' === $path ) {
				acn_site_test_assert( strlen( $text ) > 5000, "{$path} is still the abbreviated stub." );
				acn_site_test_assert( false !== strpos( $text, 'Research Dossier: Antichrist Cults and Antichrist Rhetoric' ), "{$path} is missing the packaged research dossier." );
				acn_site_test_assert( false !== strpos( $text, 'Order of Nine Angles' ), "{$path} is missing detailed case-study content." );
			}
		}
	}
);

acn_site_test_case(
	'seeds every primary navigation target',
	function () {
		foreach ( array( 'archive', 'research-agenda', 'research-library', 'timeline', 'symbols', 'apocalyptic-ai', 'state-and-religion', 'surveillance', 'community-baseline', 'about' ) as $slug ) {
			$page = get_page_by_path( $slug );
			acn_site_test_assert( $page instanceof WP_Post && 'publish' === $page->post_status, "{$slug} page missing or unpublished." );
		}
	}
);

acn_site_test_case(
	'renders the member dashboard entry points',
	function () {
		$html = do_shortcode( '[acn_member_dashboard]' );
		acn_site_test_assert( false !== strpos( $html, 'acn-member-dashboard' ), 'Member dashboard wrapper missing.' );
		acn_site_test_assert( false !== strpos( $html, '/message-board/' ), 'Member dashboard missing board link.' );
		acn_site_test_assert( false !== strpos( $html, '/members/directory/' ), 'Member dashboard missing directory link.' );
	}
);

acn_site_test_case(
	'marks faceted board listing views noindex',
	function () {
		acn_site_test_assert( function_exists( 'acn_seo_robots_content' ), 'Theme SEO robots helper is missing.' );
		$_GET['board_search'] = 'redeemer';
		try {
			acn_site_test_assert( 'noindex,follow' === acn_seo_robots_content(), 'Board search views should be noindex,follow.' );
		} finally {
			unset( $_GET['board_search'] );
		}
	}
);

acn_site_test_case(
	'keeps the primary menu aligned with the research archive navigation',
	function () {
		$locations = (array) get_theme_mod( 'nav_menu_locations', array() );
		acn_site_test_assert( ! empty( $locations['primary'] ), 'Primary menu location is not assigned.' );

		$items = wp_get_nav_menu_items( (int) $locations['primary'] );
		acn_site_test_assert( is_array( $items ), 'Primary menu items could not be read.' );
		acn_site_test_assert( 11 === count( $items ), 'Primary menu should contain the complete research archive navigation.' );

		$slugs = array();
		foreach ( $items as $item ) {
			if ( 'custom' === $item->type && untrailingslashit( (string) $item->url ) === untrailingslashit( home_url( '/' ) ) ) {
				$slugs[] = '';
			} elseif ( 'page' === $item->object && ! empty( $item->object_id ) ) {
				$page = get_post( (int) $item->object_id );
				if ( $page instanceof WP_Post ) {
					$slugs[] = $page->post_name;
				}
			}
		}

		$expected = array( '', 'archive', 'research-agenda', 'research-library', 'timeline', 'symbols', 'apocalyptic-ai', 'state-and-religion', 'surveillance', 'community-baseline', 'about' );
		acn_site_test_assert( $expected === $slugs, 'Primary menu order or targets are incorrect: ' . implode( ', ', $slugs ) );
	}
);

acn_site_test_case(
	'resolves every published catalog page for every enabled locale',
	function () {
		$enabled = acn_site_test_enabled_locales();
		$checked = 0;
		$published = 0;