From 742928f1c2db9dcff7ee4ef3edc7e264cf6a0d8b Mon Sep 17 00:00:00 2001 From: Robb Ebright Date: Tue, 8 Aug 2017 15:14:43 -0400 Subject: [PATCH] Added a test to block to test criteria for smartblock refactoring --- .../models/database/BlockDbTest.php | 70 +++++++++++++++++++ .../models/database/datasets/seed_files.yml | 47 +++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 airtime_mvc/tests/application/models/database/BlockDbTest.php create mode 100644 airtime_mvc/tests/application/models/database/datasets/seed_files.yml diff --git a/airtime_mvc/tests/application/models/database/BlockDbTest.php b/airtime_mvc/tests/application/models/database/BlockDbTest.php new file mode 100644 index 000000000..f2ec203b9 --- /dev/null +++ b/airtime_mvc/tests/application/models/database/BlockDbTest.php @@ -0,0 +1,70 @@ +_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 + } + +} \ No newline at end of file diff --git a/airtime_mvc/tests/application/models/database/datasets/seed_files.yml b/airtime_mvc/tests/application/models/database/datasets/seed_files.yml new file mode 100644 index 000000000..ce2cba1f0 --- /dev/null +++ b/airtime_mvc/tests/application/models/database/datasets/seed_files.yml @@ -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' +