portrino/codeception-sitemap-module

本包的最新版本(0.3.5)没有可用的许可信息。

解析和验证sitemap.xml文件

0.3.5 2017-10-11 05:51 UTC

This package is auto-updated.

Last update: 2024-09-20 02:17:11 UTC


README

Build Status Code Climate Test Coverage Issue Count Latest Stable Version Total Downloads

本包提供解析和验证sitemap.xml文件的功能

安装

您需要在composer.json文件中添加仓库

    composer require --dev portrino/codeception-sitemap-module

使用

您可以将此模块用作任何其他Codeception模块,只需将'Sitemap'添加到您的Codeception测试套件配置中启用的模块即可。

启用模块并设置配置变量

url可以直接在配置文件中设置,或者通过环境变量设置:%BASE_URL%

modules:
    enabled:
        - Sitemap:
            depends: PhpBrowser
            url: ADD_YOUR_BASE_URL_HERE

您还可以配置sitemap解析包的guzzle实例。例如,禁用SSL证书检查

modules:
    enabled:
      - Sitemap:
          sitemapParser:
            guzzle:
              verify: false

更新Codeception构建

  codecept build

实现cept / cest

    $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/');
  

作者

  • André Wuttig - 初始工作,单元测试,文档 - aWuttig

请参阅参与此项目的贡献者列表