示例#1
0
文件: CrudTest.php 项目: Joal01/fof
 /**
  * @group           DataModel
  * @group           DataModelCanDelete
  * @covers          FOF30\Model\DataModel::canDelete
  * @dataProvider    DataModelCrudDataprovider::getTestCanDelete
  */
 public function testCanDelete($test, $check)
 {
     $config = array('idFieldName' => 'fakeapp_parent_id', 'tableName' => '#__fakeapp_parents');
     $model = new DataModelStub(static::$container, $config);
     if ($check['exception']) {
         $this->setExpectedException($check['exception'], $check['message']);
     }
     if ($test['load']) {
         $model->find($test['load']);
     }
     $model->canDelete($test['id'], $test['joins']);
     // Fake assertion to prevent PHPUnit from complaining
     $this->assertTrue(true);
 }
示例#2
0
文件: AssetsTest.php 项目: Joal01/fof
 /**
  * @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'));
 }
示例#3
0
 /**
  * @group           DataModel
  * @group           DataModelGetAssetName
  * @covers          FOF30\Model\DataModel::getAssetName
  * @dataProvider    DataModelGenericDataprovider::getTestGetAssetName
  */
 public function testGetAssetName($test, $check)
 {
     $msg = 'DataModel::getAssetName %s - Case: ' . $check['case'];
     $config = array('idFieldName' => 'foftest_bare_id', 'tableName' => '#__foftest_bares');
     $model = new DataModelStub(static::$container, $config);
     if ($test['load']) {
         $model->find($test['load']);
     }
     ReflectionHelper::setValue($model, '_assetKey', $test['assetkey']);
     if ($check['exception']) {
         $this->setExpectedException('FOF30\\Model\\DataModel\\Exception\\NoAssetKey');
     }
     $result = $model->getAssetName();
     $this->assertEquals($check['result'], $result, sprintf($msg, 'Returned the wrong result'));
 }
示例#4
0
 /**
  * @group           DataModel
  * @group           DataModelIsLocked
  * @covers          FOF30\Model\DataModel::isLocked
  * @dataProvider    SpecialColumnsDataprovider::getTestIsLocked
  */
 public function testIsLocked($test, $check)
 {
     $msg = 'DataModel::isLocked %s - Case: ' . $check['case'];
     $config = array('idFieldName' => $test['tableid'], 'tableName' => $test['table']);
     $model = new DataModelStub(static::$container, $config);
     if ($test['load']) {
         $model->find($test['load']);
     }
     $result = $model->isLocked($test['userid']);
     $this->assertEquals($check['result'], $result, sprintf($msg, 'Returned the wrong value'));
 }