Skip to content

Commit

Permalink
Transform inline tests to real tests. The tests are suboptimal (they …
Browse files Browse the repository at this point in the history
…access an external resource) because the production code is not really testable.
  • Loading branch information
sebastianbergmann authored and scottmac committed Apr 26, 2010
1 parent a95c17e commit 7fc9bf1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
11 changes: 0 additions & 11 deletions OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,3 @@ public function key() { return key($this->_values); }
public function next() { next($this->_values); ++$this->_position; }
public function valid() { return $this->_position < sizeof($this->_values); }
}

/* tests
$test = OpenGraph::fetch('http://www.rottentomatoes.com/m/10011268-oceans/');
var_dump($test->keys());
foreach ($test AS $key => $value) {
var_dump($key, $value);
}
$test = OpenGraph::fetch('http://www.example.org');
var_dump($test);
*/
31 changes: 31 additions & 0 deletions OpenGraphTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
require 'OpenGraph.php';

class OpenGraphTest extends PHPUnit_Framework_TestCase
{
public function testFetch()
{
$o = OpenGraph::fetch(
'http://www.rottentomatoes.com/m/10011268-oceans/'
);

$this->assertType('OpenGraph', $o);

$this->assertAttributeEquals(
array(
'title' => 'Oceans',
'type' => 'movie',
'image' => 'http://images.rottentomatoes.com/images/movie/custom/68/10011268.jpg',
'url' => 'http://www.rottentomatoes.com/m/10011268-oceans/',
'site_name' => 'Rotten Tomatoes',
),
'_values',
$o
);
}

public function testFetchReturnsFalseForWebsiteWithNoOpenGraphMetadata()
{
$this->assertEquals(FALSE, OpenGraph::fetch('http://www.example.org/'));
}
}

0 comments on commit 7fc9bf1

Please sign in to comment.