Route Pages going somewhere 02

Updated readmes

I’ve udpated both Route Pages WordPress plugin and wp-routing Composer README files to take latest changes into account.

New testing power

I’ve cleaned the code and added tests to scratch itches I had about functionality here and there in both components.
I’ve been able to put WP Browser to good use and, after moving route pages activation to be triggered by a filter, I’ve used WPLoader to write a functional test like

<?php
class PageCreationTest extends \WP_UnitTestCase {

    /**
     * @test
     * it should create a page if good route meta has been persisted
     */
    public function it_should_create_a_page_if_good_route_meta_has_been_persisted() {

        // trigger route post generation
        add_filter( RoutePages::SHOULD_GENERATE_ROUTE_POSTS, '__return_true' );

        // set the route meta in the database
        $title     = 'Hello';
        $routeMeta = array(
            'hello' => array(
                'title' => $title,
                'permalink' => '^hello$',
                'generate' => 'page'
            )
        );
        add_option( WPRouting_PersistableRoute::OPTION_ID, $routeMeta );

        // make sure the page does not exist
        $this->assertNull( get_page_by_title( $title ) );

        // trigger page generation
        $sut = new RoutePages_PageManager();
        $sut->generateRoutePages();

        // check for the page to be there
        $page = get_page_by_title( $title );
        $this->assertNotNull( $page );
        $this->assertEquals( $title, $page->post_title );
        $this->assertEquals( '', $page->post_content );
        $this->assertEquals( 'hello', $page->post_name );

    }

}

which is as concise as I can make a test about WordPress functionality. Being able to run it in Codeception makes it even better Route page creation test passed

Next

More functional/service level testing and UI cleaning.