Rename airtime_mvc/ to legacy/

This commit is contained in:
jo 2021-10-11 13:43:25 +02:00
parent f0879322c2
commit 3e18d42c8b
1316 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,95 @@
<?php
//require_once "../application/configs/conf.php";
class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework_TestCase
{
private $_connectionMock;
public function setUp()
{
TestHelper::installTestDatabase();
TestHelper::setupZendBootstrap();
parent::setUp();
}
public function getConnection()
{
if ($this->_connectionMock == null) {
$config = TestHelper::getDbZendConfig();
$connection = Zend_Db::factory('pdo_pgsql', $config);
$this->_connectionMock = $this->createZendDbConnection(
$connection,
'airtimeunittests'
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
/**
* Load a dataset into the database for the block database tests
*
* Defines how the initial state of the database should look before each test is executed
* Called once during setUp() and gets recreated for each new test
*/
public function getDataSet()
{
$dataset = new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/seed_files.yml' );
return $dataset;
}
/**
* Test if the single newest file is added to the Database
*
*/
public function testGetListofFilesMeetCriteriaSingleMatch() {
TestHelper::loginUser();
$CC_CONFIG = Config::getConfig();
$testqry = CcFilesQuery::create();
$testout = $testqry->find();
$vd = $testout->getData();
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$testCriteria = BlockModelData::getCriteriaSingleNewestLabelNada();
$bltest = new Application_Model_Block();
$bltest->saveSmartBlockCriteria($testCriteria);
$tracks = $bltest->getListOfFilesUnderLimit();
//$tracks = $bltest->getLength();
$this->assertNotEmpty($tracks);
// need to load a example criteria into the database
}
/**
* Test if the single newest file is added to the Database
*
*/
public function testMultiTrackandAlbumsGetLoaded() {
TestHelper::loginUser();
$CC_CONFIG = Config::getConfig();
$testqry = CcFilesQuery::create();
$testout = $testqry->find();
$vd = $testout->getData();
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$testCriteria = BlockModelData::getCriteriaMultiTrackAndAlbum1Hour();
$bltest = new Application_Model_Block();
$bltest->saveSmartBlockCriteria($testCriteria);
$tracks = $bltest->getListOfFilesUnderLimit();
//$tracks = $bltest->getLength();
$this->assertNotEmpty($tracks);
// add assertion that the length is less than 1 hour...
// need to load a example criteria into the database
}
}

View file

@ -0,0 +1,138 @@
<?php
require_once "../application/configs/conf.php";
class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
private $_connectionMock;
public function setUp()
{
TestHelper::installTestDatabase();
$this->appBootstrap();
parent::setUp();
}
public function appBootstrap()
{
$this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH .'/configs/application.ini');
$this->application->bootstrap();
}
public function getConnection()
{
if ($this->_connectionMock == null) {
$config = TestHelper::getDbZendConfig();
$connection = Zend_Db::factory('pdo_pgsql', $config);
$this->_connectionMock = $this->createZendDbConnection(
$connection,
'airtimeunittests'
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
/* Defines how the initial state of the database should look before each test is executed
* Called once during setUp() and gets recreated for each new test
*/
public function getDataSet()
{
return new PHPUnit_Extensions_Database_DataSet_YamlDataSet(
__DIR__ . '/datasets/seed_schedule.yml'
);
}
public function testCheckOverlappingShows()
{
TestHelper::loginUser();
$data = ShowServiceData::getOverlappingShowCheckTestData();
$showService = new Application_Service_ShowService(null, $data);
/** Create shows to test against **/
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
$ds->addTable('cc_show_days', 'select * from cc_show_days order by id');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, modified_instance from cc_show_instances order by id');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
/** Make sure shows were created correctly **/
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_checkOverlappingShows.yml"),
$ds
);
$utcTimezone = new DateTimeZone("UTC");
/** Test that overlapping check works when creating a new show **/
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-02-01 00:00:00", $utcTimezone),
new DateTime("2014-02-01 01:00:00", $utcTimezone)
);
$this->assertEquals($overlapping, false);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-05 00:00:00", $utcTimezone),
new DateTime("2014-01-05 02:00:00", $utcTimezone)
);
$this->assertEquals($overlapping, true);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-05 01:00:00", $utcTimezone),
new DateTime("2014-01-05 02:00:00", $utcTimezone)
);
$this->assertEquals($overlapping, false);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-31 00:30:00", $utcTimezone),
new DateTime("2014-01-31 01:30:00", $utcTimezone)
);
$this->assertEquals($overlapping, true);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-20 23:55:00", $utcTimezone),
new DateTime("2014-01-21 00:00:05", $utcTimezone)
);
$this->assertEquals($overlapping, true);
/** Test overlapping check works when editing an entire show **/
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-05 00:00:00", $utcTimezone),
new DateTime("2014-01-05 02:00:00", $utcTimezone),
true,
null,
1
);
$this->assertEquals($overlapping, false);
/** Delete a repeating instance, create a new show in it's place and
* test if we can modify the repeating show after **/
$ccShowInstance = CcShowInstancesQuery::create()->findPk(1);
$ccShowInstance->setDbModifiedInstance(true)->save();
$newShowData = ShowServiceData::getNoRepeatNoRRData();
$newShowData["add_show_start_date"] = "2014-01-05";
$newShowData["add_show_end_date_no_repeat"] = "2014-01-05";
$newShowData["add_show_end_date"] = "2014-01-05";
$showService->addUpdateShow($newShowData);
$overlapping = Application_Model_Schedule::checkOverlappingShows(
new DateTime("2014-01-06 00:00:00", $utcTimezone),
new DateTime("2014-01-06 00:30:00", $utcTimezone),
true,
null,
1
);
$this->assertEquals($overlapping, false);
}
}

View file

@ -0,0 +1,177 @@
cc_music_dirs:
-
id: '1'
directory: '/tmp/libretime-test'
type: 'stor'
exists: 't'
watched: 't'
cc_files:
-
id: '1'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/oneminute.mp3'
mtime: '2017-08-06 04:27:36'
utime: '2017-08-06 04:26:47'
track_title: 'oneminute.mp3'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:00'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '2586748'
-
id: '2'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/fiveminute.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'fiveminute.mp3'
bit_rate: '320000'
sample_rate: '44100'
length: '00:05:00'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'
-
id: '3'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/track1.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'track1'
album_title: 'album1'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:30'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'
id: '4'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/track2.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'track2'
album_title: 'album1'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:30'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'
id: '5'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/track3.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'track3'
album_title: 'album1'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:30'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'
id: '6'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/track1-2.mp3'
mtime: '2017-08-06 05:28:36'
utime: '2017-08-16 04:27:47'
track_title: 'track1'
album_title: 'album2'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:30'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'
id: '7'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/track2-2.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'track2'
album_title: 'album2'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:30'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'

View file

@ -0,0 +1,11 @@
cc_pref:
-
id: '1'
subjid: null
keystr: shows_populated_until
valstr: '2014-02-01 00:00:00'
-
id: '2'
subjid: null
keystr: timezone
valstr: UTC

View file

@ -0,0 +1,270 @@
cc_show:
-
id: '1'
name: 'test show'
url: null
genre: null
description: null
color: ffffff
background_color: '364492'
live_stream_using_airtime_auth: false
live_stream_using_custom_auth: false
live_stream_user: null
live_stream_pass: null
linked: false
is_linkable: true
image_path: ''
has_autoplaylist: false
autoplaylist_id: null
autoplaylist_repeat: false
cc_show_days:
-
id: '1'
first_show: '2014-01-05'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '0'
repeat_type: '0'
next_pop_date: '2014-02-02'
show_id: '1'
record: '0'
-
id: '2'
first_show: '2014-01-06'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '1'
repeat_type: '0'
next_pop_date: '2014-02-03'
show_id: '1'
record: '0'
-
id: '3'
first_show: '2014-01-07'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '2'
repeat_type: '0'
next_pop_date: '2014-02-04'
show_id: '1'
record: '0'
-
id: '4'
first_show: '2014-01-08'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '3'
repeat_type: '0'
next_pop_date: '2014-02-05'
show_id: '1'
record: '0'
-
id: '5'
first_show: '2014-01-09'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '4'
repeat_type: '0'
next_pop_date: '2014-02-06'
show_id: '1'
record: '0'
-
id: '6'
first_show: '2014-01-10'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '5'
repeat_type: '0'
next_pop_date: '2014-02-07'
show_id: '1'
record: '0'
-
id: '7'
first_show: '2014-01-11'
last_show: null
start_time: '00:00:00'
timezone: UTC
duration: '01:00'
day: '6'
repeat_type: '0'
next_pop_date: '2014-02-01'
show_id: '1'
record: '0'
cc_show_instances:
-
id: '1'
starts: '2014-01-05 00:00:00'
ends: '2014-01-05 01:00:00'
show_id: '1'
modified_instance: false
-
id: '2'
starts: '2014-01-12 00:00:00'
ends: '2014-01-12 01:00:00'
show_id: '1'
modified_instance: false
-
id: '3'
starts: '2014-01-19 00:00:00'
ends: '2014-01-19 01:00:00'
show_id: '1'
modified_instance: false
-
id: '4'
starts: '2014-01-26 00:00:00'
ends: '2014-01-26 01:00:00'
show_id: '1'
modified_instance: false
-
id: '5'
starts: '2014-01-06 00:00:00'
ends: '2014-01-06 01:00:00'
show_id: '1'
modified_instance: false
-
id: '6'
starts: '2014-01-13 00:00:00'
ends: '2014-01-13 01:00:00'
show_id: '1'
modified_instance: false
-
id: '7'
starts: '2014-01-20 00:00:00'
ends: '2014-01-20 01:00:00'
show_id: '1'
modified_instance: false
-
id: '8'
starts: '2014-01-27 00:00:00'
ends: '2014-01-27 01:00:00'
show_id: '1'
modified_instance: false
-
id: '9'
starts: '2014-01-07 00:00:00'
ends: '2014-01-07 01:00:00'
show_id: '1'
modified_instance: false
-
id: '10'
starts: '2014-01-14 00:00:00'
ends: '2014-01-14 01:00:00'
show_id: '1'
modified_instance: false
-
id: '11'
starts: '2014-01-21 00:00:00'
ends: '2014-01-21 01:00:00'
show_id: '1'
modified_instance: false
-
id: '12'
starts: '2014-01-28 00:00:00'
ends: '2014-01-28 01:00:00'
show_id: '1'
modified_instance: false
-
id: '13'
starts: '2014-01-08 00:00:00'
ends: '2014-01-08 01:00:00'
show_id: '1'
modified_instance: false
-
id: '14'
starts: '2014-01-15 00:00:00'
ends: '2014-01-15 01:00:00'
show_id: '1'
modified_instance: false
-
id: '15'
starts: '2014-01-22 00:00:00'
ends: '2014-01-22 01:00:00'
show_id: '1'
modified_instance: false
-
id: '16'
starts: '2014-01-29 00:00:00'
ends: '2014-01-29 01:00:00'
show_id: '1'
modified_instance: false
-
id: '17'
starts: '2014-01-09 00:00:00'
ends: '2014-01-09 01:00:00'
show_id: '1'
modified_instance: false
-
id: '18'
starts: '2014-01-16 00:00:00'
ends: '2014-01-16 01:00:00'
show_id: '1'
modified_instance: false
-
id: '19'
starts: '2014-01-23 00:00:00'
ends: '2014-01-23 01:00:00'
show_id: '1'
modified_instance: false
-
id: '20'
starts: '2014-01-30 00:00:00'
ends: '2014-01-30 01:00:00'
show_id: '1'
modified_instance: false
-
id: '21'
starts: '2014-01-10 00:00:00'
ends: '2014-01-10 01:00:00'
show_id: '1'
modified_instance: false
-
id: '22'
starts: '2014-01-17 00:00:00'
ends: '2014-01-17 01:00:00'
show_id: '1'
modified_instance: false
-
id: '23'
starts: '2014-01-24 00:00:00'
ends: '2014-01-24 01:00:00'
show_id: '1'
modified_instance: false
-
id: '24'
starts: '2014-01-31 00:00:00'
ends: '2014-01-31 01:00:00'
show_id: '1'
modified_instance: false
-
id: '25'
starts: '2014-01-11 00:00:00'
ends: '2014-01-11 01:00:00'
show_id: '1'
modified_instance: false
-
id: '26'
starts: '2014-01-18 00:00:00'
ends: '2014-01-18 01:00:00'
show_id: '1'
modified_instance: false
-
id: '27'
starts: '2014-01-25 00:00:00'
ends: '2014-01-25 01:00:00'
show_id: '1'
modified_instance: false
cc_show_rebroadcast:
cc_show_hosts:

View file

@ -0,0 +1,21 @@
<?php
require_once "../application/configs/conf.php";
class PreferenceUnitTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
TestHelper::installTestDatabase();
TestHelper::setupZendBootstrap();
parent::setUp();
}
public function testSetShowsPopulatedUntil()
{
$date = new DateTime("2040-01-01T12:00:00.000000Z");
Application_Model_Preference::SetShowsPopulatedUntil($date);
$this->assertEquals(Application_Model_Preference::GetShowsPopulatedUntil(), $date);
}
}

View file

@ -0,0 +1,78 @@
<?php
//require_once "../application/configs/conf.php";
class ScheduleUnitTest extends Zend_Test_PHPUnit_ControllerTestCase //PHPUnit_Framework_TestCase
{
public function setUp()
{
TestHelper::installTestDatabase();
TestHelper::setupZendBootstrap();
parent::setUp();
}
public function testCheckOverlappingShows()
{
}
public function testIsFileScheduledInTheFuture()
{
TestHelper::loginUser();
$CC_CONFIG = Config::getConfig();
$testShowData = ShowServiceData::getNoRepeatNoRRData();
$showService = new Application_Service_ShowService();
$futureDate = new DateTime();
$futureDate->add(new DateInterval('P1Y')); //1 year into the future
$futureDateString = $futureDate->format('Y-m-d');
$testShowData["add_show_start_date"] = $futureDateString;
$testShowData["add_show_end_date"] = $futureDateString;
$testShowData["add_show_end_date_no_repeat"] = $futureDateString;
//Fudge the "populated until" date to workaround and issue where the default
//value will prevent anything from actually being scheduled. Normally this isn't
//a problem because as soon as you view the calendar for the first time, this is
//set to a week ahead in the future.
$populateUntil = new DateTime("now", new DateTimeZone('UTC'));
$populateUntil = $populateUntil->add(new DateInterval("P2Y")); //2 years ahead in the future.
Application_Model_Preference::SetShowsPopulatedUntil($populateUntil);
//$showService->setCcShow($testShowData); //Denise says this is not needed.
$showService->addUpdateShow($testShowData); //Create show instances
// Moved creation of stor directory to TestHelper for setup
// Insert a fake file into the database
$request = $this->getRequest();
$params = $request->getParams();
$params['action'] = '';
$params['api_key'] = $CC_CONFIG["apiKey"][0];
$request->setParams($params);
$metadata = array("MDATA_KEY_FILEPATH" => "/tmp/foobar.mp3",
"MDATA_KEY_DURATION" => "00:01:00",
"is_record" => false);
//Create the file in the database via the HTTP API.
$apiController = new ApiController($this->request, $this->getResponse());
$results = $apiController->dispatchMetadata($metadata, "create");
$fileId = $results["fileid"];
$this->assertNotEquals($fileId, -1);
$this->assertEquals($fileId, 1);
//The file should not be scheduled in the future (or at all) at this point
$scheduleModel = new Application_Model_Schedule();
$scheduleModel->IsFileScheduledInTheFuture($fileId);
$this->assertEquals($scheduleModel->IsFileScheduledInTheFuture($fileId), false);
//Schedule the fake file in the test show, which should be in the future.
$showInstance = new Application_Model_ShowInstance(1);
$showInstance->addFileToShow($fileId);
//Test the function we actually want to test. :-)
$this->assertEquals($scheduleModel->IsFileScheduledInTheFuture($fileId), true);
}
}