PHP code example of portrino / codeception-sitemap-module

1. Go to this page and download the library: Download portrino/codeception-sitemap-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

portrino / codeception-sitemap-module example snippets


    $I->wantToTest('If sitemap is valid.');
    
    $I->amOnPage('sitemap_index.xml');
    
    // validation against https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
    // sitemap will be retrieved from: http://<www.domain.tld>/sitemap.xml, where http://<www.domain.tld>/ is configured in module config
    $I->seeSiteMapIsValid('sitemap.xml');
    
    // validation against https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd
    // siteindex will be retrieved from: http://<www.domain.tld>/sitemap_index.xml, where http://<www.domain.tld>/ is configured in module config
    $I->seeSiteIndexIsValid('sitemap_index.xml');

    // validate url occurence (also recursively through siteindex files!)
    
    // complete url
    $I->seeSiteMapContainsUrl('sitemap_index.xml', 'https://www.domain.tld/foo/bar/');
    
    // without base_url (checks if one of the sitemap urls contains the path) 
    $I->seeSiteMapContainsUrlPath('sitemap.xml', '/foo/bar');
    
    
    // via response object
    $I->seeSiteMapResponseContainsUrlPath('/bar/');
    $I->seeSiteMapResponseContainsUrlPath('/foo/');