PHP code example of portrino / codeception-yandex-module

1. Go to this page and download the library: Download portrino/codeception-yandex-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-yandex-module example snippets


  $I->wantToTest('If structured data for page is valid.');
  $I->amOnPage('foo/bar/');
  
  $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
  
  // validate all
  $I->seeResponseContainsValidStructuredDataMarkup();
  // validate only JSON+LD
  $I->seeResponseContainsValidJsonLdMarkup();
  // validate only Microdata
  $I->seeResponseContainsValidMicrodataMarkup();
  // validate only Microformat
  $I->seeResponseContainsValidMicroformatMarkup();
  // validate only Rdfa
  $I->seeResponseContainsValidRdfaMarkup();
  
  // grab the data array from Yandex API response
  // @see: https://tech.yandex.com/validator/doc/dg/concepts/response_standart-docpage/
  $data = $I->grabStructuredDataFromApiResponse()['json-ld'];
  
  // grab the data from Yandex API response via jsonPath 
  // !Important: All chars like . // / and - are replaced by _ to make jsonPath working! 
  $I->assertEquals(
      'foo.com',
      $I->grabStructuredDataFromApiResponseByJsonPath('json_ld.0.http___schema_org_name.0._value')[0]
  );
  

  $I->seeResponseContainsValidStructuredDataMarkup();
  

  $I->seeResponseContainsValidJsonLdMarkup();
  

  $I->seeResponseContainsValidMicrodataMarkup();
  

  $I->seeResponseContainsValidMicroformatMarkup();
  

  $I->seeResponseContainsValidRdfaMarkup();
  

  $data = $I->grabStructuredDataFromApiResponse();
  

  $data = $I->grabStructuredDataFromApiResponseByJsonPath('json_ld.0.http___schema_org_name.0._value');