AzuraCast/tests/Functional/Api_RequestsCest.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2016-10-23 04:14:12 +02:00
<?php
namespace Functional;
use App\Entity;
class Api_RequestsCest extends CestAbstract
2016-10-23 04:14:12 +02:00
{
/**
* @before setupComplete
*/
public function checkRequestsAPI(\FunctionalTester $I): void
2016-10-23 04:14:12 +02:00
{
$I->wantTo('Check request API endpoints.');
// Enable requests on station.
$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.
$media = $this->uploadTestSong();
2016-10-23 04:14:12 +02:00
$playlist = new Entity\StationPlaylist($testStation);
$playlist->setName('Test Playlist');
2016-10-23 04:14:12 +02:00
$this->em->persist($playlist);
$spm = new Entity\StationPlaylistMedia($playlist, $media);
$this->em->persist($spm);
2016-10-23 04:14:12 +02:00
$this->em->flush();
$this->em->clear();
2016-10-23 04:14:12 +02:00
$I->sendGET('/api/station/' . $station_id . '/requests');
2016-10-23 04:14:12 +02:00
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
2016-10-23 04:14:12 +02:00
$I->sendGET('/api/station/' . $station_id . '/request/' . $media->getUniqueId());
2016-10-23 04:14:12 +02:00
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
2016-10-23 04:14:12 +02:00
}
}