2016-10-23 02:14:12 +00:00
|
|
|
<?php
|
2019-09-29 07:50:24 +00:00
|
|
|
|
2022-03-17 00:04:40 +00:00
|
|
|
namespace Functional;
|
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
use App\Entity;
|
|
|
|
|
2021-06-12 08:40:01 +00:00
|
|
|
class Api_RequestsCest extends CestAbstract
|
2016-10-23 02:14:12 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @before setupComplete
|
|
|
|
*/
|
2022-03-17 00:04:40 +00:00
|
|
|
public function checkRequestsAPI(\FunctionalTester $I): void
|
2016-10-23 02:14:12 +00:00
|
|
|
{
|
|
|
|
$I->wantTo('Check request API endpoints.');
|
|
|
|
|
|
|
|
// Enable requests on station.
|
2020-06-26 20:22:53 +00:00
|
|
|
$testStation = $this->getTestStation();
|
|
|
|
$station_id = $testStation->getId();
|
|
|
|
|
|
|
|
$testStation->setEnableRequests(true);
|
|
|
|
$this->em->persist($testStation);
|
2016-10-23 02:14:12 +00:00
|
|
|
$this->em->flush();
|
|
|
|
|
|
|
|
// Upload a test song.
|
2020-11-10 03:06:48 +00:00
|
|
|
$media = $this->uploadTestSong();
|
2016-10-23 02:14:12 +00:00
|
|
|
|
2020-06-26 20:22:53 +00:00
|
|
|
$playlist = new Entity\StationPlaylist($testStation);
|
2017-08-17 18:28:48 +00:00
|
|
|
$playlist->setName('Test Playlist');
|
2016-10-23 02:14:12 +00:00
|
|
|
$this->em->persist($playlist);
|
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
$spm = new Entity\StationPlaylistMedia($playlist, $media);
|
2018-04-29 23:48:48 +00:00
|
|
|
$this->em->persist($spm);
|
|
|
|
|
2016-10-23 02:14:12 +00:00
|
|
|
$this->em->flush();
|
2020-06-26 20:22:53 +00:00
|
|
|
$this->em->clear();
|
2016-10-23 02:14:12 +00:00
|
|
|
|
2019-09-29 07:50:24 +00:00
|
|
|
$I->sendGET('/api/station/' . $station_id . '/requests');
|
2016-10-23 02:14:12 +00:00
|
|
|
|
|
|
|
$I->seeResponseIsJson();
|
2017-06-30 03:35:30 +00:00
|
|
|
$I->seeResponseCodeIs(200);
|
2016-10-23 02:14:12 +00:00
|
|
|
|
2019-09-29 07:50:24 +00:00
|
|
|
$I->sendGET('/api/station/' . $station_id . '/request/' . $media->getUniqueId());
|
2016-10-23 02:14:12 +00:00
|
|
|
|
|
|
|
$I->seeResponseIsJson();
|
2017-06-30 03:35:30 +00:00
|
|
|
$I->seeResponseCodeIs(200);
|
2016-10-23 02:14:12 +00:00
|
|
|
}
|
|
|
|
}
|