More tests and fixing minor issues with station spinup/down.
This commit is contained in:
parent
f1d33f4104
commit
b805f6c0c6
|
@ -224,12 +224,7 @@ class StationRepository extends Repository
|
|||
// Save changes and continue to the last setup step.
|
||||
$this->em->flush();
|
||||
|
||||
$storageLocations = [
|
||||
$station->getMediaStorageLocation(),
|
||||
$station->getRecordingsStorageLocation(),
|
||||
];
|
||||
|
||||
foreach ($storageLocations as $storageLocation) {
|
||||
foreach ($station->getAllStorageLocations() as $storageLocation) {
|
||||
$stations = $this->storageLocationRepo->getStationsUsingLocation($storageLocation);
|
||||
if (1 === count($stations)) {
|
||||
$this->em->remove($storageLocation);
|
||||
|
|
|
@ -895,6 +895,16 @@ class Station implements Stringable
|
|||
$this->podcasts_storage_location = $storageLocation;
|
||||
}
|
||||
|
||||
/** @return StorageLocation[] */
|
||||
public function getAllStorageLocations(): array
|
||||
{
|
||||
return [
|
||||
$this->getMediaStorageLocation(),
|
||||
$this->getRecordingsStorageLocation(),
|
||||
$this->getPodcastsStorageLocation(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getPermissions(): Collection
|
||||
{
|
||||
return $this->permissions;
|
||||
|
|
|
@ -56,9 +56,9 @@ class Configuration
|
|||
}
|
||||
|
||||
$this->em->persist($station);
|
||||
$this->em->persist($station->getMediaStorageLocation());
|
||||
$this->em->persist($station->getRecordingsStorageLocation());
|
||||
$this->em->persist($station->getPodcastsStorageLocation());
|
||||
foreach ($station->getAllStorageLocations() as $storageLocation) {
|
||||
$this->em->persist($storageLocation);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||
use App\Environment;
|
||||
use Codeception\Configuration;
|
||||
use Codeception\Lib\Framework;
|
||||
|
@ -22,7 +23,7 @@ class Module extends Framework implements DoctrineProvider
|
|||
|
||||
public App $app;
|
||||
|
||||
public EntityManagerInterface $em;
|
||||
public ReloadableEntityManagerInterface $em;
|
||||
|
||||
protected $requiredFields = ['container'];
|
||||
|
||||
|
@ -42,7 +43,7 @@ class Module extends Framework implements DoctrineProvider
|
|||
);
|
||||
|
||||
$this->container = $this->app->getContainer();
|
||||
$this->em = $this->container->get(EntityManagerInterface::class);
|
||||
$this->em = $this->container->get(ReloadableEntityManagerInterface::class);
|
||||
|
||||
parent::_initialize();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||
use App\Entity;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
abstract class CestAbstract
|
||||
|
@ -14,7 +14,7 @@ abstract class CestAbstract
|
|||
|
||||
protected Entity\Repository\StationRepository $stationRepo;
|
||||
|
||||
protected EntityManagerInterface $em;
|
||||
protected ReloadableEntityManagerInterface $em;
|
||||
|
||||
protected string $login_username = 'azuracast@azuracast.com';
|
||||
protected string $login_password = 'AzuraCastFunctionalTests!';
|
||||
|
@ -102,7 +102,7 @@ abstract class CestAbstract
|
|||
protected function getTestStation(): Entity\Station
|
||||
{
|
||||
if ($this->test_station instanceof Entity\Station) {
|
||||
$testStation = $this->em->find(Entity\Station::class, $this->test_station->getId());
|
||||
$testStation = $this->em->refetch($this->test_station);
|
||||
if ($testStation instanceof Entity\Station) {
|
||||
return $testStation;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,53 @@ class Frontend_PublicCest extends CestAbstract
|
|||
{
|
||||
$I->wantTo('Verify that the public page displays.');
|
||||
|
||||
// Disable public pages
|
||||
$testStation = $this->getTestStation();
|
||||
$testStation->setEnablePublicPage(false);
|
||||
$this->em->persist($testStation);
|
||||
$this->em->flush();
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId());
|
||||
$I->seeResponseCodeIs(500);
|
||||
|
||||
$I->seeCurrentUrlEquals('/public/' . $testStation->getId());
|
||||
// Enable public pages
|
||||
$testStation = $this->getTestStation();
|
||||
$testStation->setEnablePublicPage(true);
|
||||
$this->em->persist($testStation);
|
||||
$this->em->flush();
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId());
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->see($testStation->getName());
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/embed');
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/history');
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/playlist.pls');
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/playlist.m3u');
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
// Disable WebDJ
|
||||
$testStation = $this->getTestStation();
|
||||
$testStation->setEnableStreamers(false);
|
||||
$this->em->persist($testStation);
|
||||
$this->em->flush();
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/dj');
|
||||
$I->seeResponseCodeIs(500);
|
||||
|
||||
// Enable WebDJ
|
||||
$testStation = $this->getTestStation();
|
||||
$testStation->setEnableStreamers(true);
|
||||
$this->em->persist($testStation);
|
||||
$this->em->flush();
|
||||
|
||||
$I->amOnPage('/public/' . $testStation->getId() . '/dj');
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue