Skip to content
Merged
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
15 changes: 15 additions & 0 deletions app/code/core/Mage/Core/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,21 @@ public function deleteConfig($path, $scope = 'default', $scopeId = 0)
return $this;
}


/**
* Get config value from DB
*
* @param string $path
* @param string $scope
* @param int $scopeId
* @return string|false
*/
public function getConfig(string $path, string $scope = 'default', int $scopeId = 0)
{
$resource = $this->getResourceModel();
return $resource->getConfig(rtrim($path, '/'), $scope, $scopeId);
}

/**
* Get fieldset from configuration
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Resource/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function deleteConfig($path, $scope, $scopeId)
* @param int $scopeId
* @return string|false
*/
public function getValue(string $path, string $scope = 'default', int $scopeId = 0)
public function getConfig(string $path, string $scope, int $scopeId)
{
$readAdapter = $this->_getReadAdapter();
$select = $readAdapter->select()
Expand Down
37 changes: 37 additions & 0 deletions dev/tests/unit/Mage/Core/Model/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace OpenMage\Tests\Unit\Mage\Core\Model;

use Mage;
use Mage_Core_Model_Config;
use PHPUnit\Framework\TestCase;

class ConfigTest extends TestCase
{
/**
* @var Mage_Core_Model_Config
*/
public Mage_Core_Model_Config $subject;

public function setUp(): void
{
Mage::app();
$this->subject = Mage::getModel('core/config');
}

public function testSaveDeleteGetConfig(): void
{
$path = 'test/config';
$value = 'foo';

$this->assertFalse($this->subject->getConfig($path));

$this->subject->saveConfig($path, $value);
$this->assertEquals($value, $this->subject->getConfig($path));

$this->subject->deleteConfig($path);
$this->assertFalse($this->subject->getConfig($path));
}
}