Added a test to block to test criteria for smartblock refactoring

This commit is contained in:
Robb Ebright 2017-08-08 15:14:43 -04:00
parent f1e467c3e6
commit 742928f1c2
2 changed files with 117 additions and 0 deletions
airtime_mvc/tests/application/models/database

View File

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

View File

@ -0,0 +1,47 @@
cc_files:
-
id: '1'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/oneminute.mp3'
mtime: '2017-08-06 04:27:36'
utime: '2017-08-06 04:26:47'
track_title: 'oneminute.mp3'
bit_rate: '320000'
sample_rate: '44100'
length: '00:01:00'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '2586748'
-
id: '2'
mime: 'audio/mp3'
ftype: 'audioclip'
directory: '1'
filepath: 'imported/1/fiveminute.mp3'
mtime: '2017-08-06 04:28:36'
utime: '2017-08-06 04:27:47'
track_title: 'fiveminute.mp3'
bit_rate: '320000'
sample_rate: '44100'
length: '00:05:00'
channels: '2'
genre: 'test'
label: 'nada'
owner_id: '1'
file_exists: 't'
hidden: 'f'
silan_check: 'f'
is_scheduled: 'f'
is_playlist: 'f'
filesize: '5126748'