<?php


require_once realpath(dirname(__FILE__) . '/../../autoload.php');

class UrlShortenerTests extends BaseTest
{
  /** @var Google_UrlshortenerService */
  public $service;

  public function __construct()
  {
    parent::__construct();
    $this->service = new Google_Service_Urlshortener($this->getClient());
  }

  public function testUrlShort()
  {
    $url = new Google_Service_Urlshortener_Url();
    $url->longUrl = "http://google.com";

    $shortUrl = $this->service->url->insert($url);
    $this->assertEquals('urlshortener#url', $shortUrl['kind']);
    $this->assertEquals('http://google.com/', $shortUrl['longUrl']);
  }

  public function testEmptyJsonResponse()
  {
    $optParams = array('fields' => '');
    $resp = $this->service->url->get('http://goo.gl/KkHq8', $optParams);

    $this->assertEquals("", $resp->longUrl);
  }
}
