1

I'm currently building some unit tests, and have just started playing around with WP_Mock. I'd like to test a function that fetches the site description; I want to test if it responds as expected when the site description is set to empty. Is there any way to mock update_option('blogdescription', '')? I've tried the following:

    $description = get_site_description();
    // Should be 'Just another WordPress site'
    $this->assertEquals('Just another WordPress site', $description); // Passes

    // Attempt to update the site description
    \WP_Mock::wpFunction( 'update_option', array(
        'times' => 1,
        'args' => array( 'blogdescription', 'Updated description' )
    ) );

    $description = get_site_description();
    // Should return 'Updated description'
    $this->assertEquals('Updated description', $description); // Fails      

I've had no joy, and I can't find anything pertaining to options in the WP_Mock documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.