Пример #1
0
 /**
  * @group           DataModel
  * @group           DataModelSetAssetsTracked
  * @covers          FOF30\Model\DataModel::setAssetsTracked
  */
 public function testSetAssetsTracked()
 {
     $config = array('idFieldName' => 'foftest_bare_id', 'tableName' => '#__foftest_bares');
     $model = new DataModelStub(static::$container, $config);
     $model->setAssetsTracked(true);
     $value = ReflectionHelper::getValue($model, '_trackAssets');
     $this->assertEquals(true, $value, 'DataModel::setAssetsTracked Returned the wrong result');
 }
Пример #2
0
 /**
  * @group           Behaviour
  * @group           AssetsOnBeforeDelete
  * @covers          FOF30\Model\DataModel\Behaviour\Assets::onBeforeDelete
  * @dataProvider    AssetsDataprovider::getTestOnBeforeDelete
  */
 public function testOnBeforeDelete($test, $check)
 {
     $msg = 'Own::onBeforeDelete %s - Case: ' . $check['case'];
     $db = \JFactory::getDbo();
     $config = array('idFieldName' => $test['tableid'], 'tableName' => $test['table']);
     $model = new DataModelStub(static::$container, $config);
     $dispatcher = $model->getBehavioursDispatcher();
     $behavior = new Assets($dispatcher);
     $model->setAssetsTracked($test['track']);
     if ($test['load']) {
         $model->find($test['load']);
     }
     if ($check['exception']) {
         $this->setExpectedException('FOF30\\Model\\DataModel\\Exception\\NoAssetKey');
     }
     $query = $db->getQuery(true)->select('COUNT(*)')->from('#__assets');
     $beforeTotal = $db->setQuery($query)->loadResult();
     $result = $behavior->onBeforeDelete($model, $test['id']);
     $this->assertTrue($result, sprintf($msg, 'Returned a wrong value'));
     $query = $db->getQuery(true)->select('COUNT(*)')->from('#__assets');
     $afterTotal = $db->setQuery($query)->loadResult();
     $this->assertEquals($check['count'], $beforeTotal - $afterTotal, sprintf($msg, 'Deleted a wrong number of assets'));
 }