Integrate SEO Forge analysis into your CI/CD pipeline or automated testing workflow.
PHPUnit Test for Minimum SEO Score
php
class SEOForge_Score_Test extends WP_UnitTestCase {
public function test_all_published_posts_have_minimum_score() {
$post_ids = get_posts( [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
] );
$analyzer = SEOFORGE_Analyzer::instance();
foreach ( $post_ids as $pid ) {
$result = $analyzer->analyze( $pid );
$this->assertGreaterThanOrEqual(
50,
$result['score'],
"Post #{$pid} '" . get_the_title( $pid ) . "' has score below 50"
);
}
}
public function test_all_posts_have_meta_description() {
$post_ids = get_posts( [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
] );
foreach ( $post_ids as $pid ) {
$desc = get_post_meta( $pid, '_seoforge_meta_description', true );
$this->assertNotEmpty(
$desc,
"Post #{$pid} is missing a meta description"
);
}
}
}WP-CLI Script for Pre-Deployment Check
php
// Run as: wp eval-file seo-check.php
if ( ! class_exists( 'SEOFORGE_Analyzer' ) ) {
WP_CLI::error( 'SEO Forge is not active.' );
}
$post_ids = get_posts( [
'post_type' => [ 'post', 'page' ], 'post_status' => 'publish',
'posts_per_page' => -1, 'fields' => 'ids',
] );
$analyzer = SEOFORGE_Analyzer::instance();
$failures = [];
foreach ( $post_ids as $pid ) {
$result = $analyzer->analyze( $pid );
if ( $result['score'] < 40 ) {
$failures[] = [
'id' => $pid,
'title' => get_the_title( $pid ),
'score' => $result['score'],
];
}
}
if ( empty( $failures ) ) {
WP_CLI::success( 'All posts pass minimum SEO score threshold.' );
} else {
WP_CLI::warning( count( $failures ) . ' posts below threshold:' );
foreach ( $failures as $f ) {
WP_CLI::log( " #{$f['id']} "{$f['title']}" - score {$f['score']}" );
}
exit( 1 );
}REST API Health Check
bash
# Check that the SEO analysis endpoint is responsive
curl -s -o /dev/null -w "%{http_code}"
-u "admin:ABCD 1234 EFGH 5678 IJKL 9012"
https://example.com/wp-json/seoforge/v1/dashboard
# Verify sitemap is accessible
curl -s -o /dev/null -w "%{http_code}" https://example.com/sitemap_index.xml—