PHP Classes

File: tests/unit/Response/ResponseTest.php

Recommend this page to a friend!
  Classes of Oleksii Mylotskyi   KeywordTool Client   tests/unit/Response/ResponseTest.php   Download  
File: tests/unit/Response/ResponseTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: KeywordTool Client
Get search engines keyword volume and suggestions
Author: By
Last change:
Date: 8 years ago
Size: 1,080 bytes
 

Contents

Class file image Download
<?php
namespace KWTClient\Tests\Unit\Response;

use
KWTClient\Response\Response;

/**
 * @runTestsInSeparateProcesses
 * @preserveGlobalState disabled
 */
class ResponseTest extends \PHPUnit_Framework_TestCase
{
    public function
testGetKeywords()
    {
       
$jsonFile = dirname($GLOBALS['configurationFilePath']) . '/' . $GLOBALS['GOOGLE_KW_RESPONSE_JSON_FILE'];
        if (!
file_exists($jsonFile)) {
            die (
"Could not found json response for parse");
        }

       
$response = new \GuzzleHttp\Psr7\Response(200, [],
                            \
GuzzleHttp\Psr7\stream_for(fopen($jsonFile, 'r')));

       
$kwResponse = new Response($response);
       
$keywords = $kwResponse->getKeywords();

       
$this->assertEquals(1483, count($keywords));
        foreach (
$keywords as $keyword) {
           
$this->assertEquals(['kw', 'vol'], array_keys($keyword));
           
$this->assertInternalType('int', $keyword['vol']);
           
$this->assertInternalType('string', $keyword['kw']);
           
$this->assertNotEmpty($keyword['kw']);
        }
    }
}