Skip to content

[6.0] Remove CMS DB aware trait #45340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 6.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/psr12/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
<exclude-pattern type="relative">libraries/src/Encrypt/Totp\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Form/Field/CaptchaField\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Input/Json\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/DatabaseAwareTrait\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/FormBehaviorTrait\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/ItemModel\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/StateBehaviorTrait\.php</exclude-pattern>
Expand Down
79 changes: 0 additions & 79 deletions libraries/src/MVC/Model/DatabaseAwareTrait.php

This file was deleted.

1 change: 0 additions & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
<exclude-pattern type="relative">libraries/src/Form/Field/CaptchaField\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Input/Json\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/Installer/Manifest\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/DatabaseAwareTrait\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/FormBehaviorTrait\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/ItemModel\.php</exclude-pattern>
<exclude-pattern type="relative">libraries/src/MVC/Model/StateBehaviorTrait\.php</exclude-pattern>
Expand Down
46 changes: 0 additions & 46 deletions tests/Unit/Libraries/Cms/MVC/Model/DatabaseModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Exception;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\MVC\Model\DatabaseAwareTrait;
use Joomla\CMS\Table\Table;
use Joomla\CMS\User\User;
use Joomla\Database\DatabaseInterface;
Expand Down Expand Up @@ -303,49 +302,4 @@ public function testCheckedOutWitFieldEmptyUserSet()

$this->assertTrue($model->isCheckedOut((object)['checked_out' => 1]));
}

/**
* @testdox still can use the old trait
*
* @return void
*
* @since 4.2.0
*
* @deprecated 5.0 Must be removed when trait gets deleted
*/
public function testUseOldMVCTrait()
{
$db = $this->createStub(DatabaseInterface::class);

$model = new class (['dbo' => $db], $this->createStub(MVCFactoryInterface::class)) extends BaseDatabaseModel {
use DatabaseAwareTrait;
};

$this->assertEquals($db, $model->getDbo());
}

/**
* @testdox operates normally even when no variable is declared
*
* @return void
*
* @since 4.2.0
*
* @deprecated 5.0 This has to be removed when we do not support the MVC Trait anymore
*/
public function testNotDeclaredVariable()
{
$model = new class (['dbo' => $this->createStub(DatabaseInterface::class)], $this->createStub(MVCFactoryInterface::class)) extends BaseDatabaseModel {
public function cache($key, $value)
{
if (!isset($this->test[$key])) {
$this->test[$key] = $value;
}

return $this->test[$key];
}
};

$this->assertEquals('test', $model->cache(1, 'test'));
}
}