Skip to content

Commit

Permalink
Test against empty parsed data
Browse files Browse the repository at this point in the history
  • Loading branch information
chojnicki committed Feb 14, 2021
1 parent e8c8189 commit 4d27d3f
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions tests/VideoPlatformsParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testGetYouTubeUrlOnApiDisabled()
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand All @@ -33,17 +34,17 @@ public function testGetYouTubeUrlOnApiDisabled()
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetShortenYouTubeUrlOnApiDisabled()
{
$url = 'https://youtu.be/watch?v=jofNR_WkoCE';
$url = 'https://youtu.be/jofNR_WkoCE';
$params = [
'youtube_api_disabled' => true,
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand All @@ -52,7 +53,6 @@ public function testGetShortenYouTubeUrlOnApiDisabled()
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetYouTubeUrlOnApiEnabled()
Expand All @@ -65,6 +65,7 @@ public function testGetYouTubeUrlOnApiEnabled()
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand All @@ -85,6 +86,7 @@ public function testGetDailymotionUrlOnApiDisabled()
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand All @@ -93,7 +95,6 @@ public function testGetDailymotionUrlOnApiDisabled()
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetVimeoUrlOnApiDisabled()
Expand All @@ -104,6 +105,7 @@ public function testGetVimeoUrlOnApiDisabled()
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand All @@ -112,22 +114,37 @@ public function testGetVimeoUrlOnApiDisabled()
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetStreamableUrlOnApiDisabled()
{
$url = 'https://streamable.com/9f5cev';
$url = 'https://streamable.com/1625tt';
$params = [
'streamable_api_disabled' => true,
];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
}

public function testGetStreamableUrlOnApiEnabled()
{
$url = 'https://streamable.com/1625tt';
$params = [];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('description', $result);
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
Expand All @@ -140,15 +157,14 @@ public function testGetLiveLeakUrl()
$params = [];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('description', $result);
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetFacebookUrl()
Expand All @@ -157,15 +173,14 @@ public function testGetFacebookUrl()
$params = [];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('description', $result);
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetTwitterUrlOnApiDisabled()
Expand All @@ -174,15 +189,14 @@ public function testGetTwitterUrlOnApiDisabled()
$params = ['twitter_api_disabled' => true];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('description', $result);
$this->assertArrayHasKey('thumbnail', $result);
$this->assertArrayHasKey('tags', $result);
$this->assertArrayHasKey('duration', $result);
$this->assertArrayHasKey('api', $result);
}

public function testGetTwitterUrlOnApiEnabled()
Expand All @@ -193,6 +207,7 @@ public function testGetTwitterUrlOnApiEnabled()
$params = ['twitter_api_bearer_token' => $this->apiKeys['twitter']];
$videoPlatformsParser = new VideoPlatformsParser($params);
$result = $videoPlatformsParser->get($url);
$result = array_filter($result);

$this->assertArrayHasKey('id', $result);
$this->assertArrayHasKey('platform', $result);
Expand Down

0 comments on commit 4d27d3f

Please sign in to comment.