Skip to content

Commit

Permalink
Merge pull request #48 from oldskool/test-fix
Browse files Browse the repository at this point in the history
Remove Twitter related unit tests
  • Loading branch information
Caroga authored Aug 3, 2016
2 parents cfc5615 + 04e7d7e commit 337142a
Showing 1 changed file with 1 addition and 69 deletions.
70 changes: 1 addition & 69 deletions src/OhTenPHP/Website/SiteBundle/Tests/Twig/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public function testGetFilters()
$filters = $extension->getFilters();

$expectedFilters = [
'tweetText',
'tweetUser',
'retweet',
'meetupSafePhotoLink',
];

$filterNames = array_map(function (\Twig_SimpleFilter $filter) {
Expand All @@ -25,70 +23,4 @@ public function testGetFilters()
$this->assertContains($expected, $filterNames);
}
}

/**
* @dataProvider tweets
*/
public function testFilterTweetText($tweet, $expected)
{
$extension = new Extension();
$filteredText = $extension->filterTweetText($tweet);

$this->assertSame($expected->text, $filteredText);
}

/**
* @dataProvider tweets
*/
public function testFilterTweetUser($tweet, $expected)
{
$extension = new Extension();
$user = $extension->filterTweetUser($tweet);

$this->assertSame($expected->user, $user);
}

/**
* @dataProvider tweets
*/
public function testFilterRetweet($tweet, $expected)
{
$extension = new Extension();
$retweet = $extension->filterRetweet($tweet);

$this->assertSame($expected->retweet, $retweet);
}

public function tweets()
{
$tweet1 = new \stdClass();
$tweet1->user = new \stdClass();
$tweet1->user->screen_name = 'reenlokum';
$tweet1->user->name = 'Reen Lokum';
$tweet1->text = 'Hello @010php or was it #010php? https://010php.nl';

$expected1 = new \stdClass();
$expected1->text = 'Hello <a href="https://twitter.com/010php">@010php</a> or was it';
$expected1->text .= ' <a href="https://twitter.com/hashtag/010php">#010php</a>? <a href="https://010php.nl">https://010php.nl</a>';
$expected1->user = '<a href="https://twitter.com/reenlokum">Reen Lokum <small class="text-muted">@reenlokum</small></a>';
$expected1->retweet = '';

$tweet2 = new \stdClass();
$tweet2->user = new \stdClass();
$tweet2->user->screen_name = 'Caroganet';
$tweet2->user->name = 'Caroga';
$tweet2->text = 'RT @reenlokum Hello @010php or was it #010php? https://010php.nl';
$tweet2->retweeted_status = $tweet1;

$expected2 = new \stdClass();
$expected2->text = 'Hello <a href="https://twitter.com/010php">@010php</a> or was it';
$expected2->text .= ' <a href="https://twitter.com/hashtag/010php">#010php</a>? <a href="https://010php.nl">https://010php.nl</a>';
$expected2->user = '<a href="https://twitter.com/reenlokum">Reen Lokum <small class="text-muted">@reenlokum</small></a>';
$expected2->retweet = '<a href="https://twitter.com/Caroganet">Caroga</a>';

return [
[$tweet1, $expected1],
[$tweet2, $expected2],
];
}
}

0 comments on commit 337142a

Please sign in to comment.