PHP Classes

File: tests/unit/Request/RequestTest.php

Recommend this page to a friend!
  Classes of Oleksii Mylotskyi  >  KeywordTool Client  >  tests/unit/Request/RequestTest.php  >  Download  
File: tests/unit/Request/RequestTest.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: 5 years ago
Size: 1,373 bytes
 

Contents

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

use
KWTClient\Request\Request;

class
RequestTest extends \PHPUnit_Framework_TestCase
{
    public function
testDefaultConstructorBehaviour()
    {
       
$keyword = 'keyword_test';
       
$serviceUrl = 'http://some.api.url.com/test';
       
$request = new Request($keyword, $serviceUrl);

       
$this->assertEquals($serviceUrl.'?keyword='.$keyword, (string)$request->getUri());
    }

    public function
testUseAllParams()
    {
       
$keyword = 'keyword_test';
       
$country = 'es';
       
$language = 'es';
       
$excludeKeywords = ['exclude', 'exclude_1'];
       
$serviceUrl = 'http://some.api.url.com/test';

       
$request = new Request($keyword, $serviceUrl);
       
$request->complete(true)
                ->
country('es')
                ->
type()
                ->
excludeKeywords($excludeKeywords)
                ->
language('es')
                ->
metrics(true);

       
$params = ['keyword' => $keyword,
                  
'complete'=>'true',
                  
'country'=>$country,
                  
'type'=>'suggestions',
                  
'exclude'=>join('|', $excludeKeywords),
                  
'language'=>$language,
                  
'metrics'=>'true'];
       
       
$this->assertEquals($serviceUrl.'?'.\GuzzleHttp\Psr7\build_query($params), (string)$request->getUri());
    }
}

For more information send a message to info at phpclasses dot org.