<commit_before><?php
namespace Czim\CmsModels\Test\Strategies\Form\Store;

use Czim\CmsModels\ModelInformation\Data\Form\ModelFormFieldData;
use Czim\CmsModels\Strategies\Form\Store\StaplerStrategy;
use Czim\CmsModels\Test\Helpers\Models\TestPost;
use Czim\CmsModels\Test\TestCase;

/**
 * Class StaplerStrategyTest
 *
 * @group strategies
 * @group strategies-form-store
 */
class StaplerStrategyTest extends TestCase
{

    /**
     * @test
     */
    function it_retrieves_a_value_from_a_model()
    {
        $model = new TestPost;
        $model->test = 'test';

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        static::assertEquals('test', $strategy->retrieve($model, 'test'));
    }

    /**
     * @test
     */
    function it_stores_a_value_on_a_model_if_keep_is_not_flagged()
    {
        $model = new TestPost;
        $model->test = false;

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        $strategy->store($model, 'test', [
            'keep'   => false,
            'upload' => 'testing',
        ]);

        static::assertEquals('testing', $model->test);
    }

    /**
     * @test
     */
    function it_does_not_store_a_value_on_a_model_if_keep_is_flagged()
    {
        $model = new TestPost;
        $model->test = false;

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        $strategy->store($model, 'test', [
            'keep'   => true,
            'upload' => 'testing',
        ]);

        static::assertFalse($model->test);
    }

}<commit_msg>Fixed test for stapler store strategy<commit_after><?php
namespace Czim\CmsModels\Test\Strategies\Form\Store;

use Czim\CmsCore\Contracts\Modules\ModuleManagerInterface;
use Czim\CmsCore\Support\Enums\Component;
use Czim\CmsModels\ModelInformation\Data\Form\ModelFormFieldData;
use Czim\CmsModels\Strategies\Form\Store\StaplerStrategy;
use Czim\CmsModels\Test\Helpers\Models\TestPost;
use Czim\CmsModels\Test\TestCase;
use Mockery;

/**
 * Class StaplerStrategyTest
 *
 * @group strategies
 * @group strategies-form-store
 */
class StaplerStrategyTest extends TestCase
{

    /**
     * @test
     */
    function it_retrieves_a_value_from_a_model()
    {
        $model = new TestPost;
        $model->test = 'test';

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        static::assertEquals('test', $strategy->retrieve($model, 'test'));
    }

    /**
     * @test
     */
    function it_stores_a_value_on_a_model_if_keep_is_not_flagged()
    {
        $this->app->instance(Component::MODULES, $this->getMockModules());

        $model = new TestPost;
        $model->test = false;

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        $strategy->store($model, 'test', [
            'keep'   => false,
            'upload' => 'testing',
        ]);

        static::assertEquals('testing', $model->test);
    }

    /**
     * @test
     */
    function it_does_not_store_a_value_on_a_model_if_keep_is_flagged()
    {
        $this->app->instance(Component::MODULES, $this->getMockModules());

        $model = new TestPost;
        $model->test = false;

        $data = new ModelFormFieldData;

        $strategy = new StaplerStrategy;
        $strategy->setFormFieldData($data);

        $strategy->store($model, 'test', [
            'keep'   => true,
            'upload' => 'testing',
        ]);

        static::assertFalse($model->test);
    }

    /**
     * @return ModuleManagerInterface|Mockery\MockInterface|Mockery\Mock
     */
    protected function getMockModules()
    {
        /** @var ModuleManagerInterface|Mockery\MockInterface|Mockery\Mock $manager */
        $manager = Mockery::mock(ModuleManagerInterface::class);

        $manager->shouldReceive('get')->with('file-uploader')->andReturn(null);

        return $manager;
    }

}
{'fraction_non_alphanumeric': 0.1354993983152828, 'fraction_numerical': 0.0, 'mean_word_length': 2.6520210896309315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '130621', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1307, 'n_words': 196}