Support Log in

41. Automated SEO Testing

Developer Guide
Prefer video? Watch the Rank Forge tutorials 9 short guides covering every feature Watch

Integrate Rank Forge analysis into your CI/CD pipeline or automated testing workflow.

PHPUnit Test for Minimum SEO Score

php
class RankForge_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 = RANKFORGE_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, '_rankforge_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( 'RANKFORGE_Analyzer' ) ) {
    WP_CLI::error( 'Rank Forge is not active.' );
}

$post_ids = get_posts( [
    'post_type' => [ 'post', 'page' ], 'post_status' => 'publish',
    'posts_per_page' => -1, 'fields' => 'ids',
] );

$analyzer = RANKFORGE_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/rankforge/v1/dashboard

# Verify sitemap is accessible
curl -s -o /dev/null -w "%{http_code}" https://example.com/sitemap_index.xml

Forge AI Assistant Online

Hi! I'm the Rank Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs