Skip to content

Commit

Permalink
Cleaned up tests after renaming classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Stump committed Apr 28, 2009
1 parent 3c6fdbe commit 88ef647
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
21 changes: 21 additions & 0 deletions README.textile
Expand Up @@ -54,3 +54,24 @@ var_dump($short);
?>
</code>
</pre>

h3. Extracting known URLs

If you have a blob of text that may or may not contain short URLs in it, you can easily extract them with the <code>Services_ShortURL::extract() method. This method looks through the text for known short URLs, extracts them, expands them and then returns an array with a key/value pair of short/long URLs.

<pre>
<code>
<?php

$url = 'http://tinyurl.com/jumvn';
require_once 'Services/ShortURL.php';

$api = Services_ShortURL::factory('TinyURL');
$long = $api->expand($url);

// Should be http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
var_dump($short);

?>
</code>
</pre>
8 changes: 4 additions & 4 deletions package.xml
Expand Up @@ -37,21 +37,21 @@
<file name="ShortURL.php"
role="php" />
<dir name="ShortURL">
<file name="bitly.php"
<file name="Bitly.php"
role="php" />
<file name="Common.php"
role="php" />
<file name="Digg.php"
role="php" />
<file name="Interface.php"
role="php" />
<file name="isgd.php"
<file name="Isgd.php"
role="php" />
<file name="shortie.php"
<file name="Shortie.php"
role="php" />
<file name="TinyURL.php"
role="php" />
<file name="trim.php"
<file name="Trim.php"
role="php" />
<file name="Exception.php"
role="php" />
Expand Down
24 changes: 12 additions & 12 deletions tests/Services/ShortURLTest.php
Expand Up @@ -53,10 +53,10 @@ class Services_ShortURLTest extends PHPUnit_Framework_TestCase
*/
protected $options = array(
'TinyURL' => array(),
'isgd' => array(),
'trim' => array(),
'shortie' => array(),
'bitly' => array(
'Isgd' => array(),
'Trim' => array(),
'Shortie' => array(),
'Bitly' => array(
'login' => 'servicesshorturl',
'apiKey' => 'R_242f2503a1c7ff9d07aaa1835722c42f'
),
Expand Down Expand Up @@ -143,10 +143,10 @@ public function allServices()
{
return array(
array('TinyURL'),
array('isgd'),
array('trim'),
array('shortie'),
array('bitly'),
array('Isgd'),
array('Trim'),
array('Shortie'),
array('Bitly'),
array('Digg')
);
}
Expand All @@ -155,10 +155,10 @@ public function detectServices()
{
return array(
array('http://tinyurl.com/ddef9j', 'TinyURL'),
array('http://short.ie/40yi4x', 'shortie'),
array('http://is.gd/uaPi', 'isgd'),
array('http://tr.im/jCBG', 'trim'),
array('http://bit.ly/10qgu', 'bitly'),
array('http://short.ie/40yi4x', 'Shortie'),
array('http://is.gd/uaPi', 'Isgd'),
array('http://tr.im/jCBG', 'Trim'),
array('http://bit.ly/10qgu', 'Bitly'),
array('http://digg.com/d1kAa1', 'Digg')
);
}
Expand Down

0 comments on commit 88ef647

Please sign in to comment.