<commit_before><?php
namespace HtSettingsModulerTest\Service;

use HtSettingsModule\Service\SettingsService;
use HtSettingsModule\Options\ModuleOptions;

class SettingsServiceTest extends \PHPUnit_Framework_TestCase
{
    public function testSave()
    {
        $settingsService= new SettingsService(
            new ModuleOptions,
            $this->getMock('HtSettingsModule\Mapper\SettingsMapperInterface')
        );
    }
}<commit_msg>Update tests for settigs service<commit_after><?php
namespace HtSettingsModulerTest\Service;

use HtSettingsModule\Service\SettingsService;
use HtSettingsModule\Options\ModuleOptions;
use HtSettingsModule\Entity\Parameter;

class SettingsServiceTest extends \PHPUnit_Framework_TestCase
{
    public function testInsertParameter()
    {
        $options = new ModuleOptions;
        $settingsMapper = $this->getMock('HtSettingsModule\Mapper\SettingsMapperInterface');
        $settingsService= new SettingsService(
            $options,
            $settingsMapper
        );

        $namespace  = 'network_settings';
        $name       = 'ip_address';
        $value      = '192.168.1.1';

        $parameter = new Parameter;
        $parameter->setNamespace($namespace);
        $parameter->setName($name);
        $parameter->setValue($value);

        $options->getCacheOptions()->setEnabled(true);
        $cacheManager = $this->getMock('HtSettingsModule\Service\CacheManagerInterface');
        $cacheManager->expects($this->once())
            ->method('delete')
            ->with($namespace);
        $settingsService->setCacheManager($cacheManager);

        $settingsMapper->expects($this->once())
            ->method('insertParameter')
            ->with($parameter);

        $settingsService->saveParameter($namespace, $name, $value);
    }

    public function testUpdateParameter()
    {
        $options = new ModuleOptions;
        $settingsMapper = $this->getMock('HtSettingsModule\Mapper\SettingsMapperInterface');
        $settingsService= new SettingsService(
            $options,
            $settingsMapper
        );

        $namespace  = 'network_settings';
        $name       = 'ip_address';
        $value      = '192.168.1.1';
        $newValue   = '192.168.10.1';

        $orginalParameter = new Parameter;
        $orginalParameter->setNamespace($namespace);
        $orginalParameter->setName($name);
        $orginalParameter->setValue($value);

        $newParameter = clone $orginalParameter;
        $newParameter->setValue($newValue);

        $options->getCacheOptions()->setEnabled(false);

        $settingsMapper->expects($this->once())
            ->method('findParameter')
            ->with($namespace, $name)
            ->will($this->returnValue($orginalParameter));

        $settingsMapper->expects($this->once())
            ->method('updateParameter')
            ->with($newParameter);

        $settingsService->saveParameter($namespace, $name, $newValue);
    }
}
{'fraction_non_alphanumeric': 0.12554843064461693, 'fraction_numerical': 0.008437394532568343, 'mean_word_length': 2.864406779661017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6985066', 'n_tokens_mistral': 781, 'n_tokens_neox': 758, 'n_words': 118}