<commit_before><commit_msg>Adding service context unit test.<commit_after><?php

namespace Valkyrja\Tests\Unit\Events;

use PHPUnit\Framework\TestCase;
use Valkyrja\Container\ServiceContext;

/**
 * Test the service context model.
 *
 * @author <NAME>
 */
class ServiceContextTest extends TestCase
{
    /**
     * The class to test with.
     *
     * @var \Valkyrja\Container\ServiceContext
     */
    protected $class;

    /**
     * The value to test with.
     *
     * @var string
     */
    protected $value = 'test';

    /**
     * Setup the test.
     *
     * @return void
     */
    public function setUp(): void
    {
        parent::setUp();

        $this->class = new ServiceContext();
    }

    /**
     * Test the getContextClass method's default value.
     *
     * @return void
     */
    public function testGetContextClassDefault(): void
    {
        $this->assertEquals(null, $this->class->getContextClass());
    }

    /**
     * Test the getContextClass method.
     *
     * @return void
     */
    public function testGetContextClass(): void
    {
        $this->class->setContextClass($this->value);

        $this->assertEquals($this->value, $this->class->getContextClass());
    }

    /**
     * Test the setContextClass method with null value.
     *
     * @return void
     */
    public function testSetContextClassNull(): void
    {
        $set = $this->class->setContextClass(null);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the setContextClass method.
     *
     * @return void
     */
    public function testSetContextClass(): void
    {
        $set = $this->class->setContextClass($this->value);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the getContextProperty method's default value.
     *
     * @return void
     */
    public function testGetContextPropertyDefault(): void
    {
        $this->assertEquals(null, $this->class->getContextProperty());
    }

    /**
     * Test the getContextProperty method.
     *
     * @return void
     */
    public function testGetContextProperty(): void
    {
        $this->class->setContextProperty($this->value);

        $this->assertEquals($this->value, $this->class->getContextProperty());
    }

    /**
     * Test the setContextProperty method with null value.
     *
     * @return void
     */
    public function testSetContextPropertyNull(): void
    {
        $set = $this->class->setContextProperty(null);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the setContextProperty method.
     *
     * @return void
     */
    public function testSetContextProperty(): void
    {
        $set = $this->class->setContextProperty($this->value);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the getContextMethod method's default value.
     *
     * @return void
     */
    public function testGetContextMethodDefault(): void
    {
        $this->assertEquals(null, $this->class->getContextMethod());
    }

    /**
     * Test the getContextMethod method.
     *
     * @return void
     */
    public function testGetContextMethod(): void
    {
        $this->class->setContextMethod($this->value);

        $this->assertEquals($this->value, $this->class->getContextMethod());
    }

    /**
     * Test the setContextMethod method with null value.
     *
     * @return void
     */
    public function testSetContextMethodNull(): void
    {
        $set = $this->class->setContextMethod(null);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the setContextMethod method.
     *
     * @return void
     */
    public function testSetContextMethod(): void
    {
        $set = $this->class->setContextMethod($this->value);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the getContextFunction method's default value.
     *
     * @return void
     */
    public function testGetContextFunctionDefault(): void
    {
        $this->assertEquals(null, $this->class->getContextFunction());
    }

    /**
     * Test the getContextFunction method.
     *
     * @return void
     */
    public function testGetContextFunction(): void
    {
        $this->class->setContextFunction($this->value);

        $this->assertEquals($this->value, $this->class->getContextFunction());
    }

    /**
     * Test the setContextFunction method with null value.
     *
     * @return void
     */
    public function testSetContextFunctionNull(): void
    {
        $set = $this->class->setContextFunction(null);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the setContextFunction method.
     *
     * @return void
     */
    public function testSetContextFunction(): void
    {
        $set = $this->class->setContextFunction($this->value);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the getContextClosure method's default value.
     *
     * @return void
     */
    public function testGetContextClosureDefault(): void
    {
        $this->assertEquals(null, $this->class->getContextClosure());
    }

    /**
     * Test the getContextClosure method.
     *
     * @return void
     */
    public function testGetContextClosure(): void
    {
        $value = function () {
        };
        $this->class->setContextClosure($value);

        $this->assertEquals($value, $this->class->getContextClosure());
    }

    /**
     * Test the setContextClosure method with null value.
     *
     * @return void
     */
    public function testSetContextClosureNull(): void
    {
        $set = $this->class->setContextClosure(null);

        $this->assertEquals(true, $set instanceof ServiceContext);
    }

    /**
     * Test the setContextClosure method.
     *
     * @return void
     */
    public function testSetContextClosure(): void
    {
        $set = $this->class->setContextClosure(
            function () {
            }
        );

        $this->assertEquals(true, $set instanceof ServiceContext);
    }
}
{'fraction_non_alphanumeric': 0.12921890067502412, 'fraction_numerical': 0.0, 'mean_word_length': 2.2445255474452557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, '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': '7476863', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1689, 'n_words': 367}