Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -1,4 +1,5 @@
<?php
error_reporting(E_ALL | E_STRICT);
// load composer autoloader
@ -16,34 +17,34 @@ defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
set_include_path(implode(PATH_SEPARATOR, [
realpath('./library'),
get_include_path(),
)));
]));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
set_include_path(implode(PATH_SEPARATOR, [
get_include_path(),
realpath(APPLICATION_PATH . '/../library')
)));
realpath(APPLICATION_PATH . '/../library'),
]));
// Ensure vendor/ is on the include path
set_include_path(implode(PATH_SEPARATOR, array(
set_include_path(implode(PATH_SEPARATOR, [
get_include_path(),
realpath(APPLICATION_PATH . '/../vendor'),
realpath(APPLICATION_PATH . '/../vendor/zf1s/zend-loader/library')
)));
realpath(APPLICATION_PATH . '/../vendor/zf1s/zend-loader/library'),
]));
set_include_path(implode(PATH_SEPARATOR, array(
set_include_path(implode(PATH_SEPARATOR, [
get_include_path(),
realpath(APPLICATION_PATH . '/../vendor/propel/propel1/runtime/lib')
)));
realpath(APPLICATION_PATH . '/../vendor/propel/propel1/runtime/lib'),
]));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
set_include_path(implode(PATH_SEPARATOR, [
get_include_path(),
realpath(APPLICATION_PATH . '/../../install_minimal/include')
)));
realpath(APPLICATION_PATH . '/../../install_minimal/include'),
]));
require_once CONFIG_PATH . '/constants.php';
@ -75,9 +76,9 @@ set_include_path(APPLICATION_PATH . '/../tests/application/helpers' . PATH_SEPAR
//cloud storage files
set_include_path(APPLICATION_PATH . '/cloud_storage' . PATH_SEPARATOR . get_include_path());
require_once APPLICATION_PATH.'/configs/conf.php';
require_once APPLICATION_PATH . '/configs/conf.php';
require_once 'propel/propel1/runtime/lib/Propel.php';
Propel::init("../application/configs/airtime-conf-production.php");
Propel::init('../application/configs/airtime-conf-production.php');
Zend_Session::start();

View file

@ -1,20 +1,24 @@
<?php
require_once "../application/configs/conf.php";
require_once '../application/configs/conf.php';
/**
* @internal
* @coversNothing
*/
class ConfigTest extends PHPUnit_Framework_TestCase
{
public function testIsYesValue()
{
foreach (["yes", "Yes", "True", "true", true] as $value) {
foreach (['yes', 'Yes', 'True', 'true', true] as $value) {
$this->assertEquals(Config::isYesValue($value), true);
}
foreach (["no", "No", "False", "false", false] as $value) {
foreach (['no', 'No', 'False', 'false', false] as $value) {
$this->assertEquals(Config::isYesValue($value), false);
}
foreach (["", "anything", "0", 0, "1", 1, null] as $value) {
foreach (['', 'anything', '0', 0, '1', 1, null] as $value) {
$this->assertEquals(Config::isYesValue($value), false);
}
}

View file

@ -1,21 +1,25 @@
<?php
set_include_path(__DIR__.'/../../legacy/library' . PATH_SEPARATOR . get_include_path());
#require_once('Zend/Loader/Autoloader.php');
set_include_path(__DIR__ . '/../../legacy/library' . PATH_SEPARATOR . get_include_path());
//require_once('Zend/Loader/Autoloader.php');
class AirtimeInstall
{
const CONF_DIR_BINARIES = "/usr/lib/airtime";
const CONF_DIR_WWW = "/usr/share/airtime";
const CONF_DIR_LOG = LIBRETIME_LOG_DIR;
public const CONF_DIR_BINARIES = '/usr/lib/airtime';
public const CONF_DIR_WWW = '/usr/share/airtime';
public const CONF_DIR_LOG = LIBRETIME_LOG_DIR;
public static $databaseTablesCreated = false;
public static function GetAirtimeSrcDir()
{
return __DIR__."/../../..";
return __DIR__ . '/../../..';
}
public static function GetUtilsSrcDir()
{
return __DIR__."/../../../../utils";
return __DIR__ . '/../../../../utils';
}
/**
* Ensures that the user is running this PHP script with root
* permissions. If not running with root permissions, causes the
@ -24,16 +28,18 @@ class AirtimeInstall
public static function ExitIfNotRoot()
{
// Need to check that we are superuser before running this.
if(posix_geteuid() != 0){
if (posix_geteuid() != 0) {
echo "Must be root user.\n";
exit(1);
}
}
/**
* Return the version of Airtime currently installed.
* If not installed, return null.
*
* @return NULL|string
* @return null|string
*/
public static function GetVersionInstalled()
{
@ -44,15 +50,14 @@ class AirtimeInstall
}
if (file_exists('/etc/airtime/airtime.conf')) {
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
}
else {
} else {
return null;
}
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
try {
$version = $con->query($sql)->fetchColumn(0);
} catch (PDOException $e){
} catch (PDOException $e) {
// no pref table therefore Airtime is not installed.
//We only get here if airtime database exists, but the table doesn't
//This state sometimes happens if a previous Airtime uninstall couldn't remove
@ -63,123 +68,136 @@ class AirtimeInstall
if ($version == '') {
try {
// If this table exists, then it's version 1.7.0
$sql = "SELECT * FROM cc_show_rebroadcast LIMIT 1";
$sql = 'SELECT * FROM cc_show_rebroadcast LIMIT 1';
$result = $con->query($sql)->fetchColumn(0);
$version = "1.7.0";
$version = '1.7.0';
} catch (Exception $e) {
$version = null;
}
}
return $version;
}
public static function DbTableExists($p_name)
{
$con = Propel::getConnection();
try {
$sql = "SELECT * FROM ".$p_name." LIMIT 1";
$sql = 'SELECT * FROM ' . $p_name . ' LIMIT 1';
$con->query($sql);
} catch (PDOException $e){
} catch (PDOException $e) {
return false;
}
return true;
}
public static function InstallQuery($sql, $verbose = true)
{
$con = Propel::getConnection();
try {
$con->exec($sql);
if ($verbose) {
echo "done.\n";
}
} catch (Exception $e) {
echo "Error!\n".$e->getMessage()."\n";
echo "Error!\n" . $e->getMessage() . "\n";
echo " SQL statement was:\n";
echo " ".$sql."\n\n";
echo ' ' . $sql . "\n\n";
}
}
public static function DropSequence($p_sequenceName)
{
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS $p_sequenceName", false);
AirtimeInstall::InstallQuery("DROP SEQUENCE IF EXISTS {$p_sequenceName}", false);
}
/**
* Try to connect to the database. Return true on success, false on failure.
* @param boolean $p_exitOnError
* Exit the program on failure.
* @return boolean
*
* @param bool $p_exitOnError
* Exit the program on failure
*
* @return bool
*/
public static function DbConnect($p_exitOnError = true)
{
$CC_CONFIG = Config::getConfig();
try {
$con = Propel::getConnection();
} catch (Exception $e) {
echo $e->getMessage().PHP_EOL;
echo "Database connection problem.".PHP_EOL;
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.".PHP_EOL;
echo $e->getMessage() . PHP_EOL;
echo 'Database connection problem.' . PHP_EOL;
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists" .
' with corresponding permissions.' . PHP_EOL;
if ($p_exitOnError) {
exit(1);
}
return false;
}
return true;
}
/* TODO: This function should be moved to the media-monitor
* install script. */
public static function InstallStorageDirectory()
{
$CC_CONFIG = Config::getConfig();
echo "* Storage directory setup".PHP_EOL;
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
$stor_dir = $ini["storage_dir"];
$dirs = array($stor_dir, $stor_dir."/organize");
foreach ($dirs as $dir){
echo '* Storage directory setup' . PHP_EOL;
$ini = parse_ini_file(__DIR__ . '/airtime-install.ini');
$stor_dir = $ini['storage_dir'];
$dirs = [$stor_dir, $stor_dir . '/organize'];
foreach ($dirs as $dir) {
if (!file_exists($dir)) {
if (mkdir($dir, 02775, true)){
if (mkdir($dir, 02775, true)) {
$rp = realpath($dir);
echo "* Directory $rp created".PHP_EOL;
echo "* Directory {$rp} created" . PHP_EOL;
} else {
echo "* Failed creating {$dir}".PHP_EOL;
echo "* Failed creating {$dir}" . PHP_EOL;
exit(1);
}
}
else if (is_writable($dir)) {
} elseif (is_writable($dir)) {
$rp = realpath($dir);
echo "* Skipping directory already exists: $rp".PHP_EOL;
}
else {
echo "* Skipping directory already exists: {$rp}" . PHP_EOL;
} else {
$rp = realpath($dir);
echo "* Error: Directory already exists, but is not writable: $rp".PHP_EOL;
echo "* Error: Directory already exists, but is not writable: {$rp}" . PHP_EOL;
exit(1);
}
echo "* Giving Apache permission to access $rp".PHP_EOL;
$success = chown($rp, $CC_CONFIG["webServerUser"]);
$success = chgrp($rp, $CC_CONFIG["webServerUser"]);
echo "* Giving Apache permission to access {$rp}" . PHP_EOL;
$success = chown($rp, $CC_CONFIG['webServerUser']);
$success = chgrp($rp, $CC_CONFIG['webServerUser']);
$success = chmod($rp, 0775);
}
}
public static function CreateDatabaseUser()
{
$CC_CONFIG = Config::getConfig();
echo " * Creating Airtime database user".PHP_EOL;
echo ' * Creating Airtime database user' . PHP_EOL;
$username = $CC_CONFIG['dsn']['username'];
$password = $CC_CONFIG['dsn']['password'];
$command = "echo \"CREATE USER $username ENCRYPTED PASSWORD '$password' LOGIN CREATEDB NOCREATEUSER;\" | su postgres -c /usr/bin/psql 2>/dev/null";
$command = "echo \"CREATE USER {$username} ENCRYPTED PASSWORD '{$password}' LOGIN CREATEDB NOCREATEUSER;\" | su postgres -c /usr/bin/psql 2>/dev/null";
@exec($command, $output, $results);
if ($results == 0) {
echo " * Database user '{$CC_CONFIG['dsn']['username']}' created.".PHP_EOL;
echo " * Database user '{$CC_CONFIG['dsn']['username']}' created." . PHP_EOL;
} else {
if (count($output) > 0) {
echo " * Could not create user '{$CC_CONFIG['dsn']['username']}': ".PHP_EOL;
echo " * Could not create user '{$CC_CONFIG['dsn']['username']}': " . PHP_EOL;
echo implode(PHP_EOL, $output);
}
else {
echo " * Database user '{$CC_CONFIG['dsn']['username']}' already exists.".PHP_EOL;
} else {
echo " * Database user '{$CC_CONFIG['dsn']['username']}' already exists." . PHP_EOL;
}
}
}
public static function CreateDatabase()
{
$CC_CONFIG = Config::getConfig();
@ -188,26 +206,30 @@ class AirtimeInstall
$password = $CC_CONFIG['dsn']['password'];
$hostspec = $CC_CONFIG['dsn']['hostspec'];
echo " * Creating Airtime database: " . $database . PHP_EOL;
echo ' * Creating Airtime database: ' . $database . PHP_EOL;
$dbExists = false;
try {
$con = pg_connect('user='.$username.' password='.$password.' host='.$hostspec);
pg_query($con, 'CREATE DATABASE '.$database.' WITH ENCODING \'UTF8\' TEMPLATE template0 OWNER '.$username.';');
$con = pg_connect('user=' . $username . ' password=' . $password . ' host=' . $hostspec);
pg_query($con, 'CREATE DATABASE ' . $database . ' WITH ENCODING \'UTF8\' TEMPLATE template0 OWNER ' . $username . ';');
} catch (Exception $e) {
// rethrow if not a "database already exists" error
if ($e->getCode() != 2 && strpos($e->getMessage(), 'already exists') !== false) throw $e;
echo " * Database already exists." . PHP_EOL;
if ($e->getCode() != 2 && strpos($e->getMessage(), 'already exists') !== false) {
throw $e;
}
echo ' * Database already exists.' . PHP_EOL;
$dbExists = true;
}
if (!$dbExists) {
echo " * Database $database created.".PHP_EOL;
echo " * Database {$database} created." . PHP_EOL;
}
return $dbExists;
}
public static function InstallPostgresScriptingLanguage()
{
$con = Propel::getConnection();
@ -215,29 +237,33 @@ class AirtimeInstall
$sql = 'SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'';
$langIsInstalled = $con->query($sql)->fetchColumn(0);
if ($langIsInstalled == '0') {
echo " * Installing Postgres scripting language".PHP_EOL;
echo ' * Installing Postgres scripting language' . PHP_EOL;
$sql = "CREATE LANGUAGE 'plpgsql'";
AirtimeInstall::InstallQuery($sql, false);
} else {
echo " * Postgres scripting language already installed".PHP_EOL;
echo ' * Postgres scripting language already installed' . PHP_EOL;
}
}
public static function CreateDatabaseTables($p_dbuser, $p_dbpasswd, $p_dbname, $p_dbhost)
{
echo " * Creating database tables".PHP_EOL;
echo ' * Creating database tables' . PHP_EOL;
// Put Propel sql files in Database
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
$dir = self::GetAirtimeSrcDir()."/build/sql/";
$files = array("schema.sql", "sequences.sql", "views.sql", "triggers.sql", "defaultdata.sql");
foreach ($files as $f){
$command = "export PGPASSWORD=$p_dbpasswd && /usr/bin/psql --username $p_dbuser --dbname $p_dbname --host $p_dbhost --file $dir$f 2>&1";
$dir = self::GetAirtimeSrcDir() . '/build/sql/';
$files = ['schema.sql', 'sequences.sql', 'views.sql', 'triggers.sql', 'defaultdata.sql'];
foreach ($files as $f) {
$command = "export PGPASSWORD={$p_dbpasswd} && /usr/bin/psql --username {$p_dbuser} --dbname {$p_dbname} --host {$p_dbhost} --file {$dir}{$f} 2>&1";
@exec($command, $output, $results);
}
AirtimeInstall::$databaseTablesCreated = true;
}
public final static function UpdateDatabaseTables() {
final public static function UpdateDatabaseTables()
{
UpgradeManager::doUpgrade();
}
public static function SetAirtimeVersion($p_version)
{
$con = Propel::getConnection();
@ -245,59 +271,68 @@ class AirtimeInstall
$con->exec($sql);
Application_Model_Preference::SetAirtimeVersion($p_version);
}
public static function SetUniqueId()
{
$uniqueId = md5(uniqid("", true));
$uniqueId = md5(uniqid('', true));
Application_Model_Preference::SetUniqueId($uniqueId);
}
public static function GetAirtimeVersion()
{
$config = Config::getConfig();
return $config['airtime_version'];
}
public static function DeleteFilesRecursive($p_path)
{
$command = "rm -rf \"$p_path\"";
$command = "rm -rf \"{$p_path}\"";
exec($command);
}
public static function InstallPhpCode()
{
$CC_CONFIG = Config::getConfig();
echo "* Installing PHP code to ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
exec("mkdir -p ".AirtimeInstall::CONF_DIR_WWW);
exec("cp -R ".AirtimeInstall::GetAirtimeSrcDir()."/* ".AirtimeInstall::CONF_DIR_WWW);
echo '* Installing PHP code to ' . AirtimeInstall::CONF_DIR_WWW . PHP_EOL;
exec('mkdir -p ' . AirtimeInstall::CONF_DIR_WWW);
exec('cp -R ' . AirtimeInstall::GetAirtimeSrcDir() . '/* ' . AirtimeInstall::CONF_DIR_WWW);
}
public static function UninstallPhpCode()
{
echo "* Removing PHP code from ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
exec('rm -rf "'.AirtimeInstall::CONF_DIR_WWW.'"');
echo '* Removing PHP code from ' . AirtimeInstall::CONF_DIR_WWW . PHP_EOL;
exec('rm -rf "' . AirtimeInstall::CONF_DIR_WWW . '"');
}
public static function DirCheck()
{
echo "Legend: \"+\" means the dir/file exists, \"-\" means that it does not.".PHP_EOL;
$dirs = array(AirtimeInstall::CONF_DIR_BINARIES,
AirtimeInstall::CONF_DIR_WWW,
AirtimeIni::CONF_FILE_AIRTIME,
AirtimeIni::CONF_FILE_LIQUIDSOAP,
AirtimeIni::CONF_FILE_PYPO,
AirtimeIni::CONF_FILE_RECORDER,
"/usr/lib/airtime/pypo",
"/var/log/airtime",
"/var/log/airtime/pypo",
"/var/tmp/airtime/pypo");
foreach ($dirs as $f) {
if (file_exists($f)) {
echo "+ $f".PHP_EOL;
} else {
echo "- $f".PHP_EOL;
}
}
echo 'Legend: "+" means the dir/file exists, "-" means that it does not.' . PHP_EOL;
$dirs = [AirtimeInstall::CONF_DIR_BINARIES,
AirtimeInstall::CONF_DIR_WWW,
AirtimeIni::CONF_FILE_AIRTIME,
AirtimeIni::CONF_FILE_LIQUIDSOAP,
AirtimeIni::CONF_FILE_PYPO,
AirtimeIni::CONF_FILE_RECORDER,
'/usr/lib/airtime/pypo',
'/var/log/airtime',
'/var/log/airtime/pypo',
'/var/tmp/airtime/pypo', ];
foreach ($dirs as $f) {
if (file_exists($f)) {
echo "+ {$f}" . PHP_EOL;
} else {
echo "- {$f}" . PHP_EOL;
}
}
}
public static function CreateZendPhpLogFile(){
public static function CreateZendPhpLogFile()
{
$CC_CONFIG = Config::getConfig();
$path = AirtimeInstall::CONF_DIR_LOG;
$file = $path.'/zendphp.log';
if (!file_exists($path)){
$file = $path . '/zendphp.log';
if (!file_exists($path)) {
mkdir($path, 0755, true);
}
touch($file);
@ -305,52 +340,62 @@ class AirtimeInstall
chown($file, $CC_CONFIG['webServerUser']);
chgrp($file, $CC_CONFIG['webServerUser']);
}
public static function RemoveLogDirectories(){
public static function RemoveLogDirectories()
{
$path = AirtimeInstall::CONF_DIR_LOG;
echo "* Removing logs directory ".$path.PHP_EOL;
exec("rm -rf \"$path\"");
echo '* Removing logs directory ' . $path . PHP_EOL;
exec("rm -rf \"{$path}\"");
}
public static function removeVirtualEnvDistributeFile(){
echo "* Removing distribute-0.6.10.tar.gz".PHP_EOL;
if(file_exists('/usr/share/python-virtualenv/distribute-0.6.10.tar.gz')){
exec("rm -f /usr/share/python-virtualenv/distribute-0.6.10.tar.gz");
public static function removeVirtualEnvDistributeFile()
{
echo '* Removing distribute-0.6.10.tar.gz' . PHP_EOL;
if (file_exists('/usr/share/python-virtualenv/distribute-0.6.10.tar.gz')) {
exec('rm -f /usr/share/python-virtualenv/distribute-0.6.10.tar.gz');
}
}
public static function printUsage($opts)
{
$msg = $opts->getUsageMessage();
echo PHP_EOL."Usage: airtime-install [options]";
echo substr($msg, strpos($msg, "\n")).PHP_EOL;
echo PHP_EOL . 'Usage: airtime-install [options]';
echo substr($msg, strpos($msg, "\n")) . PHP_EOL;
}
public static function getOpts()
{
try {
$autoloader = Zend_Loader_Autoloader::getInstance();
$opts = new Zend_Console_Getopt(
array(
[
'help|h' => 'Displays usage information.',
'overwrite|o' => 'Overwrite any existing config files.',
'preserve|p' => 'Keep any existing config files.',
'no-db|n' => 'Turn off database install.',
'reinstall|r' => 'Force a fresh install of this Airtime Version',
'webonly|w' => 'Install only web files'
)
'webonly|w' => 'Install only web files',
]
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
print $e->getMessage() .PHP_EOL;
echo $e->getMessage() . PHP_EOL;
AirtimeInstall::printUsage($opts);
return NULL;
return null;
}
return $opts;
}
public static function checkPHPVersion()
{
if (PHP_VERSION_ID < 50300)
{
echo "Error: Airtime requires PHP 5.3 or greater.";
if (PHP_VERSION_ID < 50300) {
echo 'Error: Airtime requires PHP 5.3 or greater.';
return false;
}
return true;
}
}

View file

@ -8,7 +8,8 @@ class TestHelper
//pass to the adapter the submitted username and password
$authAdapter->setIdentity('admin')
->setCredential('admin');
->setCredential('admin')
;
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
@ -25,13 +26,14 @@ class TestHelper
public static function getDbZendConfig()
{
$config = Config::getConfig();
return new Zend_Config(
array(
'host' => $config['dsn']['hostspec'],
'dbname' => $config['dsn']['database'],
[
'host' => $config['dsn']['hostspec'],
'dbname' => $config['dsn']['database'],
'username' => $config['dsn']['username'],
'password' => $config['dsn']['password']
)
'password' => $config['dsn']['password'],
]
);
}
@ -40,36 +42,35 @@ class TestHelper
//We need to load the config before our app bootstrap runs. The config
//is normally
$CC_CONFIG = Config::getConfig();
$dbuser = $CC_CONFIG['dsn']['username'];
$dbpasswd = $CC_CONFIG['dsn']['password'];
$dbname = $CC_CONFIG['dsn']['database'];
$dbhost = $CC_CONFIG['dsn']['hostspec'];
$databaseAlreadyExists = AirtimeInstall::createDatabase();
if ($databaseAlreadyExists)
{
if ($databaseAlreadyExists) {
//Truncate all the tables
$con = Propel::getConnection();
$sql = "select * from pg_tables where tableowner = '${dbuser}'";
$sql = "select * from pg_tables where tableowner = '{$dbuser}'";
try {
$rows = $con->query($sql)->fetchAll();
} catch (Exception $e) {
$rows = array();
$rows = [];
}
//Add any tables that shouldn't be cleared here.
// cc_subjs - Most of Airtime requires an admin account to work, which has id=1,
// so don't clear it.
// cc_music_dirs - Has foreign key constraints against cc_files, so we clear cc_files
// cc_music_dirs - Has foreign key constraints against cc_files, so we clear cc_files
// first and clear cc_music_dirs after
$tablesToNotClear = array("cc_subjs", "cc_music_dirs");
$tablesToNotClear = ['cc_subjs', 'cc_music_dirs'];
$con->beginTransaction();
foreach ($rows as $row) {
$tablename = $row["tablename"];
if (in_array($tablename, $tablesToNotClear))
{
$tablename = $row['tablename'];
if (in_array($tablename, $tablesToNotClear)) {
continue;
}
//echo " * Clearing database table $tablename...";
@ -77,50 +78,51 @@ class TestHelper
//TRUNCATE is actually slower than DELETE in many cases:
//http://stackoverflow.com/questions/11419536/postgresql-truncation-speed
//$sql = "TRUNCATE TABLE $tablename CASCADE";
$sql = "DELETE FROM $tablename";
$sql = "DELETE FROM {$tablename}";
AirtimeInstall::InstallQuery($sql, false);
}
//Now that cc_files is empty, clearing cc_music_dirs should work
$sql = "DELETE FROM cc_music_dirs";
$sql = 'DELETE FROM cc_music_dirs';
AirtimeInstall::InstallQuery($sql, false);
// Because files are stored relative to their watch directory,
// we need to set the "stor" path before we can successfully
// create a fake file in the database.
//Copy paste from airtime-db-install.php:
$stor_dir = "/tmp";
$stor_dir = '/tmp';
$con = Propel::getConnection();
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('{$stor_dir}', 'stor')";
try {
$con->exec($sql);
} catch (Exception $e) {
echo " * Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
echo " * Message {$e->getMessage()}".PHP_EOL;
echo " * Failed inserting {$stor_dir} in cc_music_dirs" . PHP_EOL;
echo " * Message {$e->getMessage()}" . PHP_EOL;
return false;
}
$con->commit();
//Because we're DELETEing all the rows instead of using TRUNCATE (for speed),
//we have to reset the sequences so the auto-increment columns (like primary keys)
//all start at 1 again. This is hacky but it still lets all of this execute fast.
$sql = "SELECT c.relname FROM pg_class c WHERE c.relkind = 'S'";
try {
$rows = $con->query($sql)->fetchAll();
} catch (Exception $e) {
$rows = array();
$rows = [];
}
$con->beginTransaction();
foreach ($rows as $row) {
$seqrelname= $row["relname"];
$sql = "ALTER SEQUENCE ${seqrelname} RESTART WITH 1";
$seqrelname = $row['relname'];
$sql = "ALTER SEQUENCE {$seqrelname} RESTART WITH 1";
AirtimeInstall::InstallQuery($sql, false);
}
$con->commit();
}
else
{
} else {
//Create all the database tables
AirtimeInstall::CreateDatabaseTables($dbuser, $dbpasswd, $dbname, $dbhost);
AirtimeInstall::UpdateDatabaseTables();
@ -131,6 +133,7 @@ class TestHelper
{
$application = new Zend_Application(APPLICATION_ENV, CONFIG_PATH . 'application.ini');
$application->bootstrap();
return $application;
}
}

View file

@ -1,9 +1,13 @@
<?php
//require_once "../application/configs/conf.php";
/**
* @internal
* @coversNothing
*/
class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework_TestCase
{
private $_connectionMock;
public function setUp()
@ -13,7 +17,6 @@ class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework
parent::setUp();
}
public function getConnection()
{
if ($this->_connectionMock == null) {
@ -27,29 +30,26 @@ class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
/**
* Load a dataset into the database for the block database tests
* 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;
return new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/seed_files.yml');
}
/**
* Test if the single newest file is added to the Database
*
* Test if the single newest file is added to the Database.
*/
public function testGetListofFilesMeetCriteriaSingleMatch() {
public function testGetListofFilesMeetCriteriaSingleMatch()
{
TestHelper::loginUser();
$CC_CONFIG = Config::getConfig();
$testqry = CcFilesQuery::create();
@ -67,13 +67,11 @@ class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework
// need to load a example criteria into the database
}
/**
* Test if the single newest file is added to the Database
*
* Test if the single newest file is added to the Database.
*/
public function testMultiTrackandAlbumsGetLoaded() {
public function testMultiTrackandAlbumsGetLoaded()
{
TestHelper::loginUser();
$CC_CONFIG = Config::getConfig();
$testqry = CcFilesQuery::create();
@ -91,5 +89,4 @@ class BlockDbTest extends Zend_Test_PHPUnit_DatabaseTestCase //PHPUnit_Framework
// add assertion that the length is less than 1 hour...
// need to load a example criteria into the database
}
}
}

View file

@ -1,6 +1,11 @@
<?php
require_once "../application/configs/conf.php";
require_once '../application/configs/conf.php';
/**
* @internal
* @coversNothing
*/
class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
private $_connectionMock;
@ -16,7 +21,7 @@ class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
public function appBootstrap()
{
$this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH .'/configs/application.ini');
$this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$this->application->bootstrap();
}
@ -33,6 +38,7 @@ class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
@ -53,7 +59,7 @@ class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$data = ShowServiceData::getOverlappingShowCheckTestData();
$showService = new Application_Service_ShowService(null, $data);
/** Create shows to test against **/
// Create shows to test against
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
@ -65,49 +71,49 @@ class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$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 **/
// Make sure shows were created correctly
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_checkOverlappingShows.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_checkOverlappingShows.yml'),
$ds
);
$utcTimezone = new DateTimeZone("UTC");
$utcTimezone = new DateTimeZone('UTC');
/** Test that overlapping check works when creating a new show **/
/** 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)
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)
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)
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)
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)
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 **/
/** 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),
new DateTime('2014-01-05 00:00:00', $utcTimezone),
new DateTime('2014-01-05 02:00:00', $utcTimezone),
true,
null,
1
@ -115,24 +121,24 @@ class ScheduleDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$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 **/
* 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";
$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),
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

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

View file

@ -1,19 +1,23 @@
<?php
//require_once "../application/configs/conf.php";
/**
* @internal
* @coversNothing
*/
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()
@ -27,41 +31,41 @@ class ScheduleUnitTest extends Zend_Test_PHPUnit_ControllerTestCase //PHPUnit_Fr
$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;
$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.
$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];
$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);
$metadata = ['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"];
$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);
@ -70,9 +74,8 @@ class ScheduleUnitTest extends Zend_Test_PHPUnit_ControllerTestCase //PHPUnit_Fr
//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);
}
}

View file

@ -1,5 +1,6 @@
<?php
require_once "../application/configs/conf.php";
require_once '../application/configs/conf.php';
/*
* All dates in the xml files are hard coded and in the year 2044
@ -9,6 +10,10 @@ require_once "../application/configs/conf.php";
* require functions that calculate the start and end dates, and the next populate date. The
* tests would be performing the same work as the application and require tests themselves.
*/
/**
* @internal
* @coversNothing
*/
class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
private $_connectionMock;
@ -32,11 +37,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$connection = Zend_Db::factory('pdo_pgsql', $config);
$this->_connectionMock = $this->createZendDbConnection(
$connection,
$connection,
'airtimeunittests'
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
);
Zend_Db_Table_Abstract::setDefaultAdapter($connection);
}
return $this->_connectionMock;
}
@ -54,23 +60,23 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
$showService = new Application_Service_ShowService();
$data = array(
"add_show_id" => -1,
"add_show_name" => "test show",
"add_show_description" => null,
"add_show_url" => null,
"add_show_genre" => null,
"add_show_color" => "ffffff",
"add_show_background_color" => "364492",
"cb_airtime_auth" => false,
"cb_custom_auth" => false,
"custom_username" => null,
"custom_password" => null,
"add_show_linked" => false,
"add_show_has_autoplaylist" => 0,
"add_show_autoplaylist_id" => null,
"add_show_autoplaylist_repeat" => 0
);
$data = [
'add_show_id' => -1,
'add_show_name' => 'test show',
'add_show_description' => null,
'add_show_url' => null,
'add_show_genre' => null,
'add_show_color' => 'ffffff',
'add_show_background_color' => '364492',
'cb_airtime_auth' => false,
'cb_custom_auth' => false,
'custom_username' => null,
'custom_password' => null,
'add_show_linked' => false,
'add_show_has_autoplaylist' => 0,
'add_show_autoplaylist_id' => null,
'add_show_autoplaylist_repeat' => 0,
];
$showService->setCcShow($data);
@ -80,7 +86,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show', 'select * from cc_show');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_ccShowInsertedIntoDatabase.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_ccShowInsertedIntoDatabase.yml'),
$ds
);
}
@ -144,7 +150,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "1";
$data['add_show_repeat_type'] = '1';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -169,7 +175,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "4";
$data['add_show_repeat_type'] = '4';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -194,7 +200,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "5";
$data['add_show_repeat_type'] = '5';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -209,7 +215,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createQuadWeeklyRepeatNoEndNoRRShow.yml'),
$ds
);
}
@ -219,7 +225,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "2";
$data['add_show_repeat_type'] = '2';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -234,7 +240,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createMonthlyMonthlyRepeatNoEndNoRRShow.yml'),
$ds
);
}
@ -244,7 +250,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "3";
$data['add_show_repeat_type'] = '3';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -259,13 +265,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createMonthlyWeeklyRepeatNoEndNoRRShow.yml'),
$ds
);
}
/* Tests that a show instance gets deleted from it's repeating sequence properly
*/
// Tests that a show instance gets deleted from it's repeating sequence properly
public function testDeleteShowInstance()
{
TestHelper::loginUser();
@ -278,7 +283,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$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');
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances order by id');
@ -286,7 +291,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteShowInstance.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteShowInstance.yml'),
$ds
);
}
@ -299,7 +304,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_day_check"] = array(5,1,2);
$data['add_show_day_check'] = [5, 1, 2];
$service_show = new Application_Service_ShowService(null, $data);
$service_show->addUpdateShow($data);
@ -320,7 +325,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteShowInstanceAndAllFollowing.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteShowInstanceAndAllFollowing.yml'),
$ds
);
}
@ -350,7 +355,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_editRepeatingShowInstance.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_editRepeatingShowInstance.yml'),
$ds
);
}
@ -378,7 +383,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_deleteRepeatingShow.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_deleteRepeatingShow.yml'),
$ds
);
}
@ -388,13 +393,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_repeat_type"] = "1";
$data['add_show_repeat_type'] = '1';
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
//simulate the user moves forward in the calendar
$end = new DateTime("2044-03-12", new DateTimeZone("UTC"));
$end = new DateTime('2044-03-12', new DateTimeZone('UTC'));
$showService->delegateInstanceCreation(null, $end, true);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
@ -407,7 +412,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_repeatShowCreationWhenUserMovesForwardInCalendar.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_repeatShowCreationWhenUserMovesForwardInCalendar.yml'),
$ds
);
}
@ -416,9 +421,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
{
TestHelper::loginUser();
/** Test creating a linked show **/
/** Test creating a linked show */
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_linked"] = 1;
$data['add_show_linked'] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
@ -433,12 +438,12 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createLinkedShow.yml"),
$ds
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createLinkedShow.yml'),
$ds
);
}
/** Test the creation of a single record and rebroadcast(RR) show **/
/** Test the creation of a single record and rebroadcast(RR) show */
public function testCreateNoRepeatRRShow()
{
TestHelper::loginUser();
@ -457,24 +462,24 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_createNoRepeatRRShow.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_createNoRepeatRRShow.yml'),
$ds
);
}
/** Test the creation of a weekly repeating, record and rebroadcast(RR) show **/
/** Test the creation of a weekly repeating, record and rebroadcast(RR) show */
public function testEditRepeatingShowChangeNoEndOption()
{
TestHelper::loginUser();
/** Test changing the no end option on a weekly repeating show **/
/** Test changing the no end option on a weekly repeating show */
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_end_date"] = '2044-01-09';
$data["add_show_no_end"] = 0;
$data["add_show_id"] = 1;
$data['add_show_end_date'] = '2044-01-09';
$data['add_show_no_end'] = 0;
$data['add_show_id'] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
@ -489,7 +494,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_editRepeatingShowChangeNoEndOption.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_editRepeatingShowChangeNoEndOption.yml'),
$ds
);
}
@ -497,45 +502,46 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
/**
* Tests that when you remove the first repeat show day, which changes
* the show's first instance start date, updates the scheduled content
* correctly
* correctly.
*/
public function testRemoveFirstRepeatShowDayUpdatesScheduleCorrectly()
{
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2044-01-29";
$data["add_show_day_check"] = array(5,6);
$data["add_show_linked"] = 1;
$data['add_show_start_date'] = '2044-01-29';
$data['add_show_day_check'] = [5, 6];
$data['add_show_linked'] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
//insert some fake tracks into cc_schedule table
$ccFiles = new CcFiles();
$ccFiles
->setDbCueIn("00:00:00")
->setDbCueOut("00:04:32")
->save();
->setDbCueIn('00:00:00')
->setDbCueOut('00:04:32')
->save()
;
$scheduleItems = array(
0 => array(
"id" => 0,
"instance" => 1,
"timestamp" => time()
)
);
$mediaItems = array(
0 => array(
"id" => 1,
"type" => "audioclip"
)
);
$scheduleItems = [
0 => [
'id' => 0,
'instance' => 1,
'timestamp' => time(),
],
];
$mediaItems = [
0 => [
'id' => 1,
'type' => 'audioclip',
],
];
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
//delete the first repeat day
$data["add_show_day_check"] = array(6);
$data["add_show_id"] = 1;
$data['add_show_day_check'] = [6];
$data['add_show_id'] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
@ -551,7 +557,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_removeFirstRepeatShowDayUpdatesScheduleCorrectly.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_removeFirstRepeatShowDayUpdatesScheduleCorrectly.yml'),
$ds
);
}
@ -561,38 +567,39 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
TestHelper::loginUser();
$data = ShowServiceData::getWeeklyRepeatNoEndNoRRData();
$data["add_show_start_date"] = "2044-01-29";
$data["add_show_day_check"] = array(5, 6);
$data["add_show_linked"] = 1;
$data['add_show_start_date'] = '2044-01-29';
$data['add_show_day_check'] = [5, 6];
$data['add_show_linked'] = 1;
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
//insert some fake tracks into cc_schedule table
$ccFiles = new CcFiles();
$ccFiles
->setDbCueIn("00:00:00")
->setDbCueOut("00:04:32")
->save();
->setDbCueIn('00:00:00')
->setDbCueOut('00:04:32')
->save()
;
$scheduleItems = array(
0 => array(
"id" => 0,
"instance" => 1,
"timestamp" => time()
)
);
$mediaItems = array(
0 => array(
"id" => 1,
"type" => "audioclip"
)
);
$scheduleItems = [
0 => [
'id' => 0,
'instance' => 1,
'timestamp' => time(),
],
];
$mediaItems = [
0 => [
'id' => 1,
'type' => 'audioclip',
],
];
$scheduler = new Application_Model_Scheduler();
$scheduler->scheduleAfter($scheduleItems, $mediaItems);
//delete the first repeat day
$data["add_show_day_check"] = array(6);
$data["add_show_id"] = 1;
$data['add_show_day_check'] = [6];
$data['add_show_id'] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
@ -608,7 +615,7 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_schedule', 'select id, starts, ends, file_id, clip_length, fade_in, fade_out, cue_in, cue_out, instance_id, playout_status from cc_schedule');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_changeRepeatDayUpdatesScheduleCorrectly.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_changeRepeatDayUpdatesScheduleCorrectly.yml'),
$ds
);
}
@ -622,13 +629,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_repeats"] = 0;
$data["add_show_id"] = 1;
$data['add_show_repeats'] = 0;
$data['add_show_id'] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
@ -636,9 +643,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_weeklyToNoRepeat.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_weeklyToNoRepeat.yml'),
$ds
);
}
@ -652,13 +659,13 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$showService = new Application_Service_ShowService(null, $data);
$showService->addUpdateShow($data);
$data["add_show_id"] = 1;
$data["add_show_repeat_type"] = 1;
$data['add_show_id'] = 1;
$data['add_show_repeat_type'] = 1;
$showService = new Application_Service_ShowService(null, $data, true);
$showService->addUpdateShow($data);
$ds = new Zend_Test_PHPUnit_Db_DataSet_QueryDataSet(
$this->getConnection()
$this->getConnection()
);
$ds->addTable('cc_show', 'select * from cc_show');
@ -666,9 +673,9 @@ class ShowServiceDbTest extends Zend_Test_PHPUnit_DatabaseTestCase
$ds->addTable('cc_show_instances', 'select id, starts, ends, show_id, record, rebroadcast, instance_id, modified_instance from cc_show_instances');
$ds->addTable('cc_show_rebroadcast', 'select * from cc_show_rebroadcast');
$ds->addTable('cc_show_hosts', 'select * from cc_show_hosts');
$this->assertDataSetsEqual(
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . "/datasets/test_weeklyToBiWeekly.yml"),
new PHPUnit_Extensions_Database_DataSet_YamlDataSet(__DIR__ . '/datasets/test_weeklyToBiWeekly.yml'),
$ds
);
}

View file

@ -1,6 +1,11 @@
<?php
require_once "../application/configs/conf.php";
require_once '../application/configs/conf.php';
/**
* @internal
* @coversNothing
*/
class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
{
// needed for accessing private methods
@ -17,14 +22,14 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
public function testFormatShowDuration()
{
$duration = Application_Service_ShowService::formatShowDuration("01h 00m");
$this->assertEquals("01:00", $duration);
$duration = Application_Service_ShowService::formatShowDuration('01h 00m');
$this->assertEquals('01:00', $duration);
$duration = Application_Service_ShowService::formatShowDuration("00h 05m");
$this->assertEquals("00:05", $duration);
$duration = Application_Service_ShowService::formatShowDuration('00h 05m');
$this->assertEquals('00:05', $duration);
$duration = Application_Service_ShowService::formatShowDuration("03h 55m");
$this->assertEquals("03:55", $duration);
$duration = Application_Service_ShowService::formatShowDuration('03h 55m');
$this->assertEquals('03:55', $duration);
}
public function testCalculateEndDate()
@ -32,13 +37,13 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
$method = $this->_reflectionOfShowService->getMethod('calculateEndDate');
$method->setAccessible(true);
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getNoRepeatNoRRData()));
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getNoRepeatNoRRData()]);
$this->assertEquals(null, $end);
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getWeeklyRepeatWithEndNoRRData()));
$this->assertEquals(new DateTime("2044-01-27", new DateTimeZone("UTC")), $end);
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getWeeklyRepeatWithEndNoRRData()]);
$this->assertEquals(new DateTime('2044-01-27', new DateTimeZone('UTC')), $end);
$end = $method->invokeArgs($this->_showService, array(ShowServiceData::getWeeklyRepeatNoEndNoRRData()));
$end = $method->invokeArgs($this->_showService, [ShowServiceData::getWeeklyRepeatNoEndNoRRData()]);
$this->assertEquals(null, $end);
}
@ -47,20 +52,20 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
$method = $this->_reflectionOfShowService->getMethod('getMonthlyWeeklyRepeatInterval');
$method->setAccessible(true);
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-01"), new DateTimeZone("UTC")));
$this->assertEquals(array("first", "Friday"), $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-01'), new DateTimeZone('UTC')]);
$this->assertEquals(['first', 'Friday'], $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-12"), new DateTimeZone("UTC")));
$this->assertEquals(array("second", "Tuesday"), $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-12'), new DateTimeZone('UTC')]);
$this->assertEquals(['second', 'Tuesday'], $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-18"), new DateTimeZone("UTC")));
$this->assertEquals(array("third", "Monday"), $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-18'), new DateTimeZone('UTC')]);
$this->assertEquals(['third', 'Monday'], $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-28"), new DateTimeZone("UTC")));
$this->assertEquals(array("fourth", "Thursday"), $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-28'), new DateTimeZone('UTC')]);
$this->assertEquals(['fourth', 'Thursday'], $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-30"), new DateTimeZone("UTC")));
$this->assertEquals(array("fifth", "Saturday"), $repeatInterval);
$repeatInterval = $method->invokeArgs($this->_showService, [new DateTime('2044-01-30'), new DateTimeZone('UTC')]);
$this->assertEquals(['fifth', 'Saturday'], $repeatInterval);
}
public function testGetNextMonthlyMonthlyRepeatDate()
@ -68,11 +73,11 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
$method = $this->_reflectionOfShowService->getMethod('getNextMonthlyMonthlyRepeatDate');
$method->setAccessible(true);
$next = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-01"), "UTC", "00:00"));
$this->assertEquals(new DateTime("2044-02-01", new DateTimeZone("UTC")), $next);
$next = $method->invokeArgs($this->_showService, [new DateTime('2044-01-01'), 'UTC', '00:00']);
$this->assertEquals(new DateTime('2044-02-01', new DateTimeZone('UTC')), $next);
$next = $method->invokeArgs($this->_showService, array(new DateTime("2044-01-30"), "UTC", "00:00"));
$this->assertEquals(new DateTime("2044-03-30", new DateTimeZone("UTC")), $next);
$next = $method->invokeArgs($this->_showService, [new DateTime('2044-01-30'), 'UTC', '00:00']);
$this->assertEquals(new DateTime('2044-03-30', new DateTimeZone('UTC')), $next);
}
public function testGetNextMonthlyWeeklyRepeatDate()
@ -80,17 +85,17 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
$method = $this->_reflectionOfShowService->getMethod('getNextMonthlyWeeklyRepeatDate');
$method->setAccessible(true);
$next = $method->invokeArgs($this->_showService, array(
new DateTime("2044-02-01"), "UTC", "00:00", "first", "Friday"));
$this->assertEquals(new DateTime("2044-02-05", new DateTimeZone("UTC")), $next);
$next = $method->invokeArgs($this->_showService, [
new DateTime('2044-02-01'), 'UTC', '00:00', 'first', 'Friday', ]);
$this->assertEquals(new DateTime('2044-02-05', new DateTimeZone('UTC')), $next);
$next = $method->invokeArgs($this->_showService, array(
new DateTime("2044-02-01"), "UTC", "00:00", "fifth", "Saturday"));
$this->assertEquals(new DateTime("2044-04-30", new DateTimeZone("UTC")), $next);
$next = $method->invokeArgs($this->_showService, [
new DateTime('2044-02-01'), 'UTC', '00:00', 'fifth', 'Saturday', ]);
$this->assertEquals(new DateTime('2044-04-30', new DateTimeZone('UTC')), $next);
$next = $method->invokeArgs($this->_showService, array(
new DateTime("2044-02-01"), "UTC", "00:00", "fourth", "Monday"));
$this->assertEquals(new DateTime("2044-02-22", new DateTimeZone("UTC")), $next);
$next = $method->invokeArgs($this->_showService, [
new DateTime('2044-02-01'), 'UTC', '00:00', 'fourth', 'Monday', ]);
$this->assertEquals(new DateTime('2044-02-22', new DateTimeZone('UTC')), $next);
}
public function testCreateUTCStartEndDateTime()
@ -98,42 +103,42 @@ class ShowServiceUnitTest extends PHPUnit_Framework_TestCase
$method = $this->_reflectionOfShowService->getMethod('createUTCStartEndDateTime');
$method->setAccessible(true);
$utcTimezone = new DateTimeZone("UTC");
$utcTimezone = new DateTimeZone('UTC');
//America/Toronto
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Toronto"));
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Toronto"));
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Toronto'));
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Toronto'));
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
$this->assertEquals(array(
$localStartDT->setTimezone($utcTimezone),$localEndDT->setTimezone($utcTimezone)), $dt);
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
$this->assertEquals([
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
//America/Toronto with offset for rebroadcast shows
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Toronto"));
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Toronto"));
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Toronto'));
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Toronto'));
$localRebroadcastStartDT = new DateTime("2044-01-02 06:30", new DateTimeZone("America/Toronto"));
$localRebroadcastEndDT = new DateTime("2044-01-02 07:30", new DateTimeZone("America/Toronto"));
$localRebroadcastStartDT = new DateTime('2044-01-02 06:30', new DateTimeZone('America/Toronto'));
$localRebroadcastEndDT = new DateTime('2044-01-02 07:30', new DateTimeZone('America/Toronto'));
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00",
array("days" => "1", "hours" => "06", "mins" => "30")));
$this->assertEquals(array(
$localRebroadcastStartDT->setTimezone($utcTimezone),$localRebroadcastEndDT->setTimezone($utcTimezone)), $dt);
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00',
['days' => '1', 'hours' => '06', 'mins' => '30'], ]);
$this->assertEquals([
$localRebroadcastStartDT->setTimezone($utcTimezone), $localRebroadcastEndDT->setTimezone($utcTimezone), ], $dt);
//Australia/Brisbane
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("Australia/Brisbane"));
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("Australia/Brisbane"));
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('Australia/Brisbane'));
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('Australia/Brisbane'));
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
$this->assertEquals(array(
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone)), $dt);
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
$this->assertEquals([
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
//America/Vancouver
$localStartDT = new DateTime("2044-01-01 06:30", new DateTimeZone("America/Vancouver"));
$localEndDT = new DateTime("2044-01-01 07:30", new DateTimeZone("America/Vancouver"));
$localStartDT = new DateTime('2044-01-01 06:30', new DateTimeZone('America/Vancouver'));
$localEndDT = new DateTime('2044-01-01 07:30', new DateTimeZone('America/Vancouver'));
$dt = $method->invokeArgs($this->_showService, array($localStartDT, "01:00"));
$this->assertEquals(array(
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone)), $dt);
$dt = $method->invokeArgs($this->_showService, [$localStartDT, '01:00']);
$this->assertEquals([
$localStartDT->setTimezone($utcTimezone), $localEndDT->setTimezone($utcTimezone), ], $dt);
}
}

View file

@ -1,51 +1,50 @@
<?php
Class BlockModelData
class BlockModelData
{
public static function getCriteriaSingleNewestLabelNada() {
return array(
Array("name" => "sp_type", "value" => 0),
Array("name" => "sp_type", "value" => 0),
Array("name" => "sp_repeat_tracks", "value" => 0),
Array("name" => "sp_sort_options", "value" => "newest"),
Array("name" => "sp_limit_value", "value" => 1),
Array("name" => "sp_limit_options", "value" => "items"),
Array("name" => "sp_criteria_field_0_0", "value" => "label"),
Array("name" => "sp_criteria_modifier_0_0", "value" => "contains"),
Array("name" => "sp_criteria_value_0_0", "value" => "nada"),
Array("name" => "sp_overflow_tracks", "value" => 0),
);
public static function getCriteriaSingleNewestLabelNada()
{
return [
['name' => 'sp_type', 'value' => 0],
['name' => 'sp_type', 'value' => 0],
['name' => 'sp_repeat_tracks', 'value' => 0],
['name' => 'sp_sort_options', 'value' => 'newest'],
['name' => 'sp_limit_value', 'value' => 1],
['name' => 'sp_limit_options', 'value' => 'items'],
['name' => 'sp_criteria_field_0_0', 'value' => 'label'],
['name' => 'sp_criteria_modifier_0_0', 'value' => 'contains'],
['name' => 'sp_criteria_value_0_0', 'value' => 'nada'],
['name' => 'sp_overflow_tracks', 'value' => 0],
];
}
public static function getCriteriaMultiTrackAndAlbum1Hour()
{
return array (
Array("name" => "sp_type" , "value" => 1),
Array("name" => "sp_repeat_tracks", "value" => 0),
Array("name" => "sp_sort_options", "value" => "random"),
Array("name" => "sp_limit_value", "value" => 1),
Array("name" => "sp_limit_options", "value" => "hours"),
Array("name" => "sp_overflow_tracks", "value" => 0),
Array("name" => "sp_criteria_field_0_0", "value" => "album_title"),
Array("name" => "sp_criteria_modifier_0_0", "value" => "is"),
Array("name" => "sp_criteria_value_0_0", "value" => "album1"),
Array("name" => "sp_criteria_field_0_1", "value" => "album_title"),
Array("name" => "sp_criteria_modifier_0_1", "value" => "is"),
Array("name" => "sp_criteria_value_0_1", "value" => "album2"),
Array("name" => "sp_criteria_field_1_0", "value" => "track_title"),
Array("name" => "sp_criteria_modifier_1_0", "value" => "is"),
Array("name" => "sp_criteria_value_1_0", "value" => "track1"),
Array("name" => "sp_criteria_field_1_1", "value" => "track_title"),
Array("name" => "sp_criteria_modifier_1_1", "value" => "is"),
Array("name" => "sp_criteria_value_1_1", "value" => "track2"),
Array("name" => "sp_criteria_field_1_2", "value" => "track_title"),
Array("name" => "sp_criteria_modifier_1_2", "value" => "is"),
Array("name" => "sp_criteria_value_1_2", "value" => "track3"),
Array("name" => "sp_criteria_field_2_0", "value" => "length"),
Array("name" => "sp_criteria_modifier_2_0", "value" => "is greater than"),
Array("name" => "sp_criteria_value_2_0", "value" => "00:01:00"),
);
return [
['name' => 'sp_type', 'value' => 1],
['name' => 'sp_repeat_tracks', 'value' => 0],
['name' => 'sp_sort_options', 'value' => 'random'],
['name' => 'sp_limit_value', 'value' => 1],
['name' => 'sp_limit_options', 'value' => 'hours'],
['name' => 'sp_overflow_tracks', 'value' => 0],
['name' => 'sp_criteria_field_0_0', 'value' => 'album_title'],
['name' => 'sp_criteria_modifier_0_0', 'value' => 'is'],
['name' => 'sp_criteria_value_0_0', 'value' => 'album1'],
['name' => 'sp_criteria_field_0_1', 'value' => 'album_title'],
['name' => 'sp_criteria_modifier_0_1', 'value' => 'is'],
['name' => 'sp_criteria_value_0_1', 'value' => 'album2'],
['name' => 'sp_criteria_field_1_0', 'value' => 'track_title'],
['name' => 'sp_criteria_modifier_1_0', 'value' => 'is'],
['name' => 'sp_criteria_value_1_0', 'value' => 'track1'],
['name' => 'sp_criteria_field_1_1', 'value' => 'track_title'],
['name' => 'sp_criteria_modifier_1_1', 'value' => 'is'],
['name' => 'sp_criteria_value_1_1', 'value' => 'track2'],
['name' => 'sp_criteria_field_1_2', 'value' => 'track_title'],
['name' => 'sp_criteria_modifier_1_2', 'value' => 'is'],
['name' => 'sp_criteria_value_1_2', 'value' => 'track3'],
['name' => 'sp_criteria_field_2_0', 'value' => 'length'],
['name' => 'sp_criteria_modifier_2_0', 'value' => 'is greater than'],
['name' => 'sp_criteria_value_2_0', 'value' => '00:01:00'],
];
}
}
}

View file

@ -1,513 +1,514 @@
<?php
Class ShowServiceData
class ShowServiceData
{
//Just a regular show - Non repeating, and not a recording & rebroadcast show.
public static function getNoRepeatNoRRData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-01",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2044-01-01",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 0,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2044-01-01",
"add_show_no_end" => 1,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 0,
"add_show_rebroadcast" => 0,
"add_show_rebroadcast_date_absolute_1" => null,
"add_show_rebroadcast_time_absolute_1" => null,
"add_show_rebroadcast_date_absolute_2" => null,
"add_show_rebroadcast_time_absolute_2" => null,
"add_show_rebroadcast_date_absolute_3" => null,
"add_show_rebroadcast_time_absolute_3" => null,
"add_show_rebroadcast_date_absolute_4" => null,
"add_show_rebroadcast_time_absolute_4" => null,
"add_show_rebroadcast_date_absolute_5" => null,
"add_show_rebroadcast_time_absolute_5" => null,
"add_show_rebroadcast_date_absolute_6" => null,
"add_show_rebroadcast_time_absolute_6" => null,
"add_show_rebroadcast_date_absolute_7" => null,
"add_show_rebroadcast_time_absolute_7" => null,
"add_show_rebroadcast_date_absolute_8" => null,
"add_show_rebroadcast_time_absolute_8" => null,
"add_show_rebroadcast_date_absolute_9" => null,
"add_show_rebroadcast_time_absolute_9" => null,
"add_show_rebroadcast_date_absolute_10" => null,
"add_show_rebroadcast_time_absolute_10" => null,
"add_show_rebroadcast_date_1" => null,
"add_show_rebroadcast_time_1" => null,
"add_show_rebroadcast_date_2" => null,
"add_show_rebroadcast_time_2" => null,
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => null
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-01',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2044-01-01',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 0,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2044-01-01',
'add_show_no_end' => 1,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 0,
'add_show_rebroadcast' => 0,
'add_show_rebroadcast_date_absolute_1' => null,
'add_show_rebroadcast_time_absolute_1' => null,
'add_show_rebroadcast_date_absolute_2' => null,
'add_show_rebroadcast_time_absolute_2' => null,
'add_show_rebroadcast_date_absolute_3' => null,
'add_show_rebroadcast_time_absolute_3' => null,
'add_show_rebroadcast_date_absolute_4' => null,
'add_show_rebroadcast_time_absolute_4' => null,
'add_show_rebroadcast_date_absolute_5' => null,
'add_show_rebroadcast_time_absolute_5' => null,
'add_show_rebroadcast_date_absolute_6' => null,
'add_show_rebroadcast_time_absolute_6' => null,
'add_show_rebroadcast_date_absolute_7' => null,
'add_show_rebroadcast_time_absolute_7' => null,
'add_show_rebroadcast_date_absolute_8' => null,
'add_show_rebroadcast_time_absolute_8' => null,
'add_show_rebroadcast_date_absolute_9' => null,
'add_show_rebroadcast_time_absolute_9' => null,
'add_show_rebroadcast_date_absolute_10' => null,
'add_show_rebroadcast_time_absolute_10' => null,
'add_show_rebroadcast_date_1' => null,
'add_show_rebroadcast_time_1' => null,
'add_show_rebroadcast_date_2' => null,
'add_show_rebroadcast_time_2' => null,
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => null,
];
}
public static function getWeeklyRepeatNoEndNoRRData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-01",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2044-01-01",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 1,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2044-01-01",
"add_show_no_end" => 1,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 0,
"add_show_rebroadcast" => 0,
"add_show_rebroadcast_date_absolute_1" => null,
"add_show_rebroadcast_time_absolute_1" => null,
"add_show_rebroadcast_date_absolute_2" => null,
"add_show_rebroadcast_time_absolute_2" => null,
"add_show_rebroadcast_date_absolute_3" => null,
"add_show_rebroadcast_time_absolute_3" => null,
"add_show_rebroadcast_date_absolute_4" => null,
"add_show_rebroadcast_time_absolute_4" => null,
"add_show_rebroadcast_date_absolute_5" => null,
"add_show_rebroadcast_time_absolute_5" => null,
"add_show_rebroadcast_date_absolute_6" => null,
"add_show_rebroadcast_time_absolute_6" => null,
"add_show_rebroadcast_date_absolute_7" => null,
"add_show_rebroadcast_time_absolute_7" => null,
"add_show_rebroadcast_date_absolute_8" => null,
"add_show_rebroadcast_time_absolute_8" => null,
"add_show_rebroadcast_date_absolute_9" => null,
"add_show_rebroadcast_time_absolute_9" => null,
"add_show_rebroadcast_date_absolute_10" => null,
"add_show_rebroadcast_time_absolute_10" => null,
"add_show_rebroadcast_date_1" => null,
"add_show_rebroadcast_time_1" => null,
"add_show_rebroadcast_date_2" => null,
"add_show_rebroadcast_time_2" => null,
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => array(5)
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-01',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2044-01-01',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 1,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2044-01-01',
'add_show_no_end' => 1,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 0,
'add_show_rebroadcast' => 0,
'add_show_rebroadcast_date_absolute_1' => null,
'add_show_rebroadcast_time_absolute_1' => null,
'add_show_rebroadcast_date_absolute_2' => null,
'add_show_rebroadcast_time_absolute_2' => null,
'add_show_rebroadcast_date_absolute_3' => null,
'add_show_rebroadcast_time_absolute_3' => null,
'add_show_rebroadcast_date_absolute_4' => null,
'add_show_rebroadcast_time_absolute_4' => null,
'add_show_rebroadcast_date_absolute_5' => null,
'add_show_rebroadcast_time_absolute_5' => null,
'add_show_rebroadcast_date_absolute_6' => null,
'add_show_rebroadcast_time_absolute_6' => null,
'add_show_rebroadcast_date_absolute_7' => null,
'add_show_rebroadcast_time_absolute_7' => null,
'add_show_rebroadcast_date_absolute_8' => null,
'add_show_rebroadcast_time_absolute_8' => null,
'add_show_rebroadcast_date_absolute_9' => null,
'add_show_rebroadcast_time_absolute_9' => null,
'add_show_rebroadcast_date_absolute_10' => null,
'add_show_rebroadcast_time_absolute_10' => null,
'add_show_rebroadcast_date_1' => null,
'add_show_rebroadcast_time_1' => null,
'add_show_rebroadcast_date_2' => null,
'add_show_rebroadcast_time_2' => null,
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => [5],
];
}
public static function getWeeklyRepeatWithEndNoRRData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-01",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2044-01-01",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 1,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2044-01-26",
"add_show_no_end" => 0,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 0,
"add_show_rebroadcast" => 0,
"add_show_rebroadcast_date_absolute_1" => null,
"add_show_rebroadcast_time_absolute_1" => null,
"add_show_rebroadcast_date_absolute_2" => null,
"add_show_rebroadcast_time_absolute_2" => null,
"add_show_rebroadcast_date_absolute_3" => null,
"add_show_rebroadcast_time_absolute_3" => null,
"add_show_rebroadcast_date_absolute_4" => null,
"add_show_rebroadcast_time_absolute_4" => null,
"add_show_rebroadcast_date_absolute_5" => null,
"add_show_rebroadcast_time_absolute_5" => null,
"add_show_rebroadcast_date_absolute_6" => null,
"add_show_rebroadcast_time_absolute_6" => null,
"add_show_rebroadcast_date_absolute_7" => null,
"add_show_rebroadcast_time_absolute_7" => null,
"add_show_rebroadcast_date_absolute_8" => null,
"add_show_rebroadcast_time_absolute_8" => null,
"add_show_rebroadcast_date_absolute_9" => null,
"add_show_rebroadcast_time_absolute_9" => null,
"add_show_rebroadcast_date_absolute_10" => null,
"add_show_rebroadcast_time_absolute_10" => null,
"add_show_rebroadcast_date_1" => null,
"add_show_rebroadcast_time_1" => null,
"add_show_rebroadcast_date_2" => null,
"add_show_rebroadcast_time_2" => null,
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => array(5)
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-01',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2044-01-01',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 1,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2044-01-26',
'add_show_no_end' => 0,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 0,
'add_show_rebroadcast' => 0,
'add_show_rebroadcast_date_absolute_1' => null,
'add_show_rebroadcast_time_absolute_1' => null,
'add_show_rebroadcast_date_absolute_2' => null,
'add_show_rebroadcast_time_absolute_2' => null,
'add_show_rebroadcast_date_absolute_3' => null,
'add_show_rebroadcast_time_absolute_3' => null,
'add_show_rebroadcast_date_absolute_4' => null,
'add_show_rebroadcast_time_absolute_4' => null,
'add_show_rebroadcast_date_absolute_5' => null,
'add_show_rebroadcast_time_absolute_5' => null,
'add_show_rebroadcast_date_absolute_6' => null,
'add_show_rebroadcast_time_absolute_6' => null,
'add_show_rebroadcast_date_absolute_7' => null,
'add_show_rebroadcast_time_absolute_7' => null,
'add_show_rebroadcast_date_absolute_8' => null,
'add_show_rebroadcast_time_absolute_8' => null,
'add_show_rebroadcast_date_absolute_9' => null,
'add_show_rebroadcast_time_absolute_9' => null,
'add_show_rebroadcast_date_absolute_10' => null,
'add_show_rebroadcast_time_absolute_10' => null,
'add_show_rebroadcast_date_1' => null,
'add_show_rebroadcast_time_1' => null,
'add_show_rebroadcast_date_2' => null,
'add_show_rebroadcast_time_2' => null,
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => [5],
];
}
public static function getWeeklyRepeatDays()
{
return array(1,2,3,4,5);
return [1, 2, 3, 4, 5];
}
public static function getDailyRepeatDays()
{
return array(0,1,2,3,4,5,6);
return [0, 1, 2, 3, 4, 5, 6];
}
public static function getEditRepeatInstanceData()
{
return array(
"add_show_id" => 1,
"add_show_instance_id" => 2,
"add_show_name" => "test show",
"add_show_instance_description" => "",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-08",
"add_show_start_time" => "01:00",
"add_show_end_date_no_repeat" => "2044-01-08",
"add_show_end_time" => "02:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 0,
"add_show_linked" => 0,
"add_show_no_end" => 0,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"add_show_record" => 0,
"add_show_rebroadcast" => 0,
"add_show_hosts" => null
);
return [
'add_show_id' => 1,
'add_show_instance_id' => 2,
'add_show_name' => 'test show',
'add_show_instance_description' => '',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-08',
'add_show_start_time' => '01:00',
'add_show_end_date_no_repeat' => '2044-01-08',
'add_show_end_time' => '02:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 0,
'add_show_linked' => 0,
'add_show_no_end' => 0,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'add_show_record' => 0,
'add_show_rebroadcast' => 0,
'add_show_hosts' => null,
];
}
public static function getOverlappingShowCheckTestData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2014-01-05",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2014-01-05",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 1,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2014-01-05",
"add_show_no_end" => 1,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 0,
"add_show_rebroadcast" => 0,
"add_show_rebroadcast_date_absolute_1" => null,
"add_show_rebroadcast_time_absolute_1" => null,
"add_show_rebroadcast_date_absolute_2" => null,
"add_show_rebroadcast_time_absolute_2" => null,
"add_show_rebroadcast_date_absolute_3" => null,
"add_show_rebroadcast_time_absolute_3" => null,
"add_show_rebroadcast_date_absolute_4" => null,
"add_show_rebroadcast_time_absolute_4" => null,
"add_show_rebroadcast_date_absolute_5" => null,
"add_show_rebroadcast_time_absolute_5" => null,
"add_show_rebroadcast_date_absolute_6" => null,
"add_show_rebroadcast_time_absolute_6" => null,
"add_show_rebroadcast_date_absolute_7" => null,
"add_show_rebroadcast_time_absolute_7" => null,
"add_show_rebroadcast_date_absolute_8" => null,
"add_show_rebroadcast_time_absolute_8" => null,
"add_show_rebroadcast_date_absolute_9" => null,
"add_show_rebroadcast_time_absolute_9" => null,
"add_show_rebroadcast_date_absolute_10" => null,
"add_show_rebroadcast_time_absolute_10" => null,
"add_show_rebroadcast_date_1" => null,
"add_show_rebroadcast_time_1" => null,
"add_show_rebroadcast_date_2" => null,
"add_show_rebroadcast_time_2" => null,
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => array(0,1,2,3,4,5,6)
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2014-01-05',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2014-01-05',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 1,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2014-01-05',
'add_show_no_end' => 1,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 0,
'add_show_rebroadcast' => 0,
'add_show_rebroadcast_date_absolute_1' => null,
'add_show_rebroadcast_time_absolute_1' => null,
'add_show_rebroadcast_date_absolute_2' => null,
'add_show_rebroadcast_time_absolute_2' => null,
'add_show_rebroadcast_date_absolute_3' => null,
'add_show_rebroadcast_time_absolute_3' => null,
'add_show_rebroadcast_date_absolute_4' => null,
'add_show_rebroadcast_time_absolute_4' => null,
'add_show_rebroadcast_date_absolute_5' => null,
'add_show_rebroadcast_time_absolute_5' => null,
'add_show_rebroadcast_date_absolute_6' => null,
'add_show_rebroadcast_time_absolute_6' => null,
'add_show_rebroadcast_date_absolute_7' => null,
'add_show_rebroadcast_time_absolute_7' => null,
'add_show_rebroadcast_date_absolute_8' => null,
'add_show_rebroadcast_time_absolute_8' => null,
'add_show_rebroadcast_date_absolute_9' => null,
'add_show_rebroadcast_time_absolute_9' => null,
'add_show_rebroadcast_date_absolute_10' => null,
'add_show_rebroadcast_time_absolute_10' => null,
'add_show_rebroadcast_date_1' => null,
'add_show_rebroadcast_time_1' => null,
'add_show_rebroadcast_date_2' => null,
'add_show_rebroadcast_time_2' => null,
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => [0, 1, 2, 3, 4, 5, 6],
];
}
/** Returns form data for a non-repeating, record and rebroadcast(RR) show **/
/** Returns form data for a non-repeating, record and rebroadcast(RR) show */
public static function getNoRepeatRRData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-01",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2044-01-01",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 0,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2044-01-01",
"add_show_no_end" => 1,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 1,
"add_show_rebroadcast" => 1,
"add_show_rebroadcast_date_absolute_1" => "2044-01-02",
"add_show_rebroadcast_time_absolute_1" => "00:00",
"add_show_rebroadcast_date_absolute_2" => "2044-01-03",
"add_show_rebroadcast_time_absolute_2" => "00:00",
"add_show_rebroadcast_date_absolute_3" => "2044-01-04",
"add_show_rebroadcast_time_absolute_3" => "00:00",
"add_show_rebroadcast_date_absolute_4" => "2044-01-05",
"add_show_rebroadcast_time_absolute_4" => "00:00",
"add_show_rebroadcast_date_absolute_5" => "2044-01-06",
"add_show_rebroadcast_time_absolute_5" => "00:00",
"add_show_rebroadcast_date_absolute_6" => "2044-01-07",
"add_show_rebroadcast_time_absolute_6" => "00:00",
"add_show_rebroadcast_date_absolute_7" => "2044-01-08",
"add_show_rebroadcast_time_absolute_7" => "00:00",
"add_show_rebroadcast_date_absolute_8" => "2044-01-09",
"add_show_rebroadcast_time_absolute_8" => "00:00",
"add_show_rebroadcast_date_absolute_9" => "2044-01-10",
"add_show_rebroadcast_time_absolute_9" => "00:00",
"add_show_rebroadcast_date_absolute_10" => "2044-01-11",
"add_show_rebroadcast_time_absolute_10" => "00:00",
"add_show_rebroadcast_date_1" => null,
"add_show_rebroadcast_time_1" => null,
"add_show_rebroadcast_date_2" => null,
"add_show_rebroadcast_time_2" => null,
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => null
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-01',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2044-01-01',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 0,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2044-01-01',
'add_show_no_end' => 1,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 1,
'add_show_rebroadcast' => 1,
'add_show_rebroadcast_date_absolute_1' => '2044-01-02',
'add_show_rebroadcast_time_absolute_1' => '00:00',
'add_show_rebroadcast_date_absolute_2' => '2044-01-03',
'add_show_rebroadcast_time_absolute_2' => '00:00',
'add_show_rebroadcast_date_absolute_3' => '2044-01-04',
'add_show_rebroadcast_time_absolute_3' => '00:00',
'add_show_rebroadcast_date_absolute_4' => '2044-01-05',
'add_show_rebroadcast_time_absolute_4' => '00:00',
'add_show_rebroadcast_date_absolute_5' => '2044-01-06',
'add_show_rebroadcast_time_absolute_5' => '00:00',
'add_show_rebroadcast_date_absolute_6' => '2044-01-07',
'add_show_rebroadcast_time_absolute_6' => '00:00',
'add_show_rebroadcast_date_absolute_7' => '2044-01-08',
'add_show_rebroadcast_time_absolute_7' => '00:00',
'add_show_rebroadcast_date_absolute_8' => '2044-01-09',
'add_show_rebroadcast_time_absolute_8' => '00:00',
'add_show_rebroadcast_date_absolute_9' => '2044-01-10',
'add_show_rebroadcast_time_absolute_9' => '00:00',
'add_show_rebroadcast_date_absolute_10' => '2044-01-11',
'add_show_rebroadcast_time_absolute_10' => '00:00',
'add_show_rebroadcast_date_1' => null,
'add_show_rebroadcast_time_1' => null,
'add_show_rebroadcast_date_2' => null,
'add_show_rebroadcast_time_2' => null,
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => null,
];
}
public static function getWeeklyRepeatRRData()
{
return array(
"add_show_id" => -1,
"add_show_instance_id" => -1,
"add_show_name" => "test show",
"add_show_url" => null,
"add_show_genre" => null,
"add_show_description" => null,
"add_show_start_date" => "2044-01-01",
"add_show_start_time" => "00:00",
"add_show_end_date_no_repeat" => "2044-01-01",
"add_show_end_time" => "01:00",
"add_show_duration" => "01h 00m",
"add_show_timezone" => "UTC",
"add_show_has_autoplaylist" => false,
"add_show_autoplaylist_repeat" => false,
"add_show_autoplaylist_id" => null,
"add_show_repeats" => 1,
"add_show_linked" => 0,
"add_show_repeat_type" => 0,
"add_show_monthly_repeat_type" => 2,
"add_show_end_date" => "2044-01-01",
"add_show_no_end" => 1,
"cb_airtime_auth" => 0,
"cb_custom_auth" => 0,
"custom_username" => null,
"custom_password" => null,
"add_show_record" => 1,
"add_show_rebroadcast" => 1,
"add_show_rebroadcast_date_absolute_1" => null,
"add_show_rebroadcast_time_absolute_1" => null,
"add_show_rebroadcast_date_absolute_2" => null,
"add_show_rebroadcast_time_absolute_2" => null,
"add_show_rebroadcast_date_absolute_3" => null,
"add_show_rebroadcast_time_absolute_3" => null,
"add_show_rebroadcast_date_absolute_4" => null,
"add_show_rebroadcast_time_absolute_4" => null,
"add_show_rebroadcast_date_absolute_5" => null,
"add_show_rebroadcast_time_absolute_5" => null,
"add_show_rebroadcast_date_absolute_6" => null,
"add_show_rebroadcast_time_absolute_6" => null,
"add_show_rebroadcast_date_absolute_7" => null,
"add_show_rebroadcast_time_absolute_7" => null,
"add_show_rebroadcast_date_absolute_8" => null,
"add_show_rebroadcast_time_absolute_8" => null,
"add_show_rebroadcast_date_absolute_9" => null,
"add_show_rebroadcast_time_absolute_9" => null,
"add_show_rebroadcast_date_absolute_10" => null,
"add_show_rebroadcast_time_absolute_10" => null,
"add_show_rebroadcast_date_1" => "1 days",
"add_show_rebroadcast_time_1" => "00:00",
"add_show_rebroadcast_date_2" => "2 days",
"add_show_rebroadcast_time_2" => "12:00",
"add_show_rebroadcast_date_3" => null,
"add_show_rebroadcast_time_3" => null,
"add_show_rebroadcast_date_4" => null,
"add_show_rebroadcast_time_4" => null,
"add_show_rebroadcast_date_5" => null,
"add_show_rebroadcast_time_5" => null,
"add_show_rebroadcast_date_6" => null,
"add_show_rebroadcast_time_6" => null,
"add_show_rebroadcast_date_7" => null,
"add_show_rebroadcast_time_7" => null,
"add_show_rebroadcast_date_8" => null,
"add_show_rebroadcast_time_8" => null,
"add_show_rebroadcast_date_9" => null,
"add_show_rebroadcast_time_9" => null,
"add_show_rebroadcast_date_10" => null,
"add_show_rebroadcast_time_10" => null,
"add_show_hosts_autocomplete" => null,
"add_show_background_color" => "364492",
"add_show_color" => "ffffff",
"add_show_hosts" => null,
"add_show_day_check" => array(5)
);
return [
'add_show_id' => -1,
'add_show_instance_id' => -1,
'add_show_name' => 'test show',
'add_show_url' => null,
'add_show_genre' => null,
'add_show_description' => null,
'add_show_start_date' => '2044-01-01',
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeat' => '2044-01-01',
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m',
'add_show_timezone' => 'UTC',
'add_show_has_autoplaylist' => false,
'add_show_autoplaylist_repeat' => false,
'add_show_autoplaylist_id' => null,
'add_show_repeats' => 1,
'add_show_linked' => 0,
'add_show_repeat_type' => 0,
'add_show_monthly_repeat_type' => 2,
'add_show_end_date' => '2044-01-01',
'add_show_no_end' => 1,
'cb_airtime_auth' => 0,
'cb_custom_auth' => 0,
'custom_username' => null,
'custom_password' => null,
'add_show_record' => 1,
'add_show_rebroadcast' => 1,
'add_show_rebroadcast_date_absolute_1' => null,
'add_show_rebroadcast_time_absolute_1' => null,
'add_show_rebroadcast_date_absolute_2' => null,
'add_show_rebroadcast_time_absolute_2' => null,
'add_show_rebroadcast_date_absolute_3' => null,
'add_show_rebroadcast_time_absolute_3' => null,
'add_show_rebroadcast_date_absolute_4' => null,
'add_show_rebroadcast_time_absolute_4' => null,
'add_show_rebroadcast_date_absolute_5' => null,
'add_show_rebroadcast_time_absolute_5' => null,
'add_show_rebroadcast_date_absolute_6' => null,
'add_show_rebroadcast_time_absolute_6' => null,
'add_show_rebroadcast_date_absolute_7' => null,
'add_show_rebroadcast_time_absolute_7' => null,
'add_show_rebroadcast_date_absolute_8' => null,
'add_show_rebroadcast_time_absolute_8' => null,
'add_show_rebroadcast_date_absolute_9' => null,
'add_show_rebroadcast_time_absolute_9' => null,
'add_show_rebroadcast_date_absolute_10' => null,
'add_show_rebroadcast_time_absolute_10' => null,
'add_show_rebroadcast_date_1' => '1 days',
'add_show_rebroadcast_time_1' => '00:00',
'add_show_rebroadcast_date_2' => '2 days',
'add_show_rebroadcast_time_2' => '12:00',
'add_show_rebroadcast_date_3' => null,
'add_show_rebroadcast_time_3' => null,
'add_show_rebroadcast_date_4' => null,
'add_show_rebroadcast_time_4' => null,
'add_show_rebroadcast_date_5' => null,
'add_show_rebroadcast_time_5' => null,
'add_show_rebroadcast_date_6' => null,
'add_show_rebroadcast_time_6' => null,
'add_show_rebroadcast_date_7' => null,
'add_show_rebroadcast_time_7' => null,
'add_show_rebroadcast_date_8' => null,
'add_show_rebroadcast_time_8' => null,
'add_show_rebroadcast_date_9' => null,
'add_show_rebroadcast_time_9' => null,
'add_show_rebroadcast_date_10' => null,
'add_show_rebroadcast_time_10' => null,
'add_show_hosts_autocomplete' => null,
'add_show_background_color' => '364492',
'add_show_color' => 'ffffff',
'add_show_hosts' => null,
'add_show_day_check' => [5],
];
}
}