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