Permalink
Browse files

Cleaned up tests after renaming classes.

  • Loading branch information...
1 parent 3c6fdbe commit 88ef647e1f8b80110eff8bba59c4a80e5a259e94 Joe Stump committed Apr 28, 2009
Showing with 37 additions and 16 deletions.
  1. +21 −0 README.textile
  2. +4 −4 package.xml
  3. +12 −12 tests/Services/ShortURLTest.php
View
21 README.textile
@@ -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>
View
8 package.xml
@@ -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" />
View
24 tests/Services/ShortURLTest.php
@@ -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'
),
@@ -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')
);
}
@@ -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')
);
}

0 comments on commit 88ef647

Please sign in to comment.