Created
November 24, 2018 13:01
-
-
Save nevercodealone/19dfcd7886d3b4a2cce3344b36e31fef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace NCATesting\service; | |
use App\Service\YouTubeService; | |
use Codeception\Stub; | |
use NCATesting\UnitTester; | |
use Mockery as m; | |
class YouTubeServiceCest | |
{ | |
private $fixture; | |
public function _before(UnitTester $I) | |
{ | |
$_ENV['GOOGLE_API_KEY'] = 'testify'; | |
$this->fixture = new YouTubeService(); | |
} | |
// tests | |
public function getItemsFromChannelReverseArrayFromPlaylistItemsListByPlaylistId(UnitTester $I) | |
{ | |
$array = [ | |
'one', | |
'two', | |
'three' | |
]; | |
$externalMock = m::mock('overload:\Google_Service_YouTube'); | |
$externalMock->shouldReceive('foo') | |
->once() | |
->andReturn($array) | |
->set('playlistItems', 'listPlaylistItems') | |
; | |
$externalMock->playlistItems = 'listPlaylistItems'; | |
$obj = new \stdClass(); | |
$obj->playlistItems = new \stdClass(); | |
$obj->playlistItems->listPlaylistItems = $array | |
$this->fixture = Stub::make( | |
$this->fixture, | |
[ | |
'playlistItemsListByPlaylistId' => ['items' => $array] | |
] | |
); | |
$itemsFromChannel = $this->fixture->getItemsFromChannel(); | |
$I->assertSame(array_reverse($array), $itemsFromChannel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment