<commit_before><?php
namespace Colibri\tests\Session;

use Colibri\Session\Session;
use Colibri\Session\Storage\StorageInterface;
use Colibri\tests\TestCase;
use PHPUnit_Framework_MockObject_Invocation_Object;
use PHPUnit_Framework_MockObject_MockObject;

/**
 * Tests for Session class.
 *
 * @coversDefaultClass \Session
 */
class SessionTest extends TestCase
{
    /**
     * @var PHPUnit_Framework_MockObject_MockObject 121212|StorageInterface
     */
    private $storageMock;

    /**
     * @throws \InvalidArgumentException
     * @throws \PHPUnit\Framework\Exception
     * @throws \PHPUnit_Framework_MockObject_RuntimeException
     */
    protected function setUp()
    {
        // use PHPUnit mocks, because StorageInterface contains `catch`method, but Mockery can`t mock it
        $this->storageMock = $this
            ->getMockBuilder(StorageInterface::class)
            ->setMethodsExcept()
            ->getMock()
        ;

        $this->inject(Session::class, ['storage' => $this->storageMock]);
    }

    protected function tearDown()
    {
        $this->storageMock = null;
    }

    // -------------------------------------------------------------------------------------

    /**
     * @dataProvider getDataProvider
     *
     * @param string $variable
     * @param mixed  $value
     *
     * @throws \PHPUnit_Framework_MockObject_RuntimeException
     */
    public function testGet($variable, $value)
    {
        $this->storageMock
            ->expects($spy = self::once())
            ->method('get')->with($variable)
            ->willReturn($value)
        ;

        self::assertEquals($value, Session::get($variable));
        /** @var PHPUnit_Framework_MockObject_Invocation_Object $invocation */
        $invocation = $spy->getInvocations()[0];
        self::assertEquals($variable, $invocation->parameters[0]);
    }

    /**
     * @return array
     */
    public function getDataProvider()
    {
        // args: [variable name to ::get, returned value]
        return [
            ['var1', true],
            ['var2', false],<commit_msg>fix dock-blocks<commit_after><?php
namespace Colibri\tests\Session;

use Colibri\Session\Session;
use Colibri\Session\Storage\StorageInterface;
use Colibri\tests\TestCase;
use PHPUnit_Framework_MockObject_Invocation_Object;
use PHPUnit_Framework_MockObject_MockObject;

/**
 * Tests for Session class.
 *
 * @coversDefaultClass \Colibri\Session\Session
 */
class SessionTest extends TestCase
{
    /**
     * @var PHPUnit_Framework_MockObject_MockObject
     */
    private $storageMock;

    /**
     * @throws \InvalidArgumentException
     * @throws \PHPUnit\Framework\Exception
     * @throws \PHPUnit_Framework_MockObject_RuntimeException
     */
    protected function setUp()
    {
        // use PHPUnit mocks, because StorageInterface contains `catch`method, but Mockery can`t mock it
        $this->storageMock = $this
            ->getMockBuilder(StorageInterface::class)
            ->setMethodsExcept()
            ->getMock()
        ;

        $this->inject(Session::class, ['storage' => $this->storageMock]);
    }

    protected function tearDown()
    {
        $this->storageMock = null;
    }

    // -------------------------------------------------------------------------------------

    /**
     * @covers ::get
     * @dataProvider getDataProvider
     *
     * @param string $variable
     * @param mixed  $value
     *
     * @throws \PHPUnit_Framework_MockObject_RuntimeException
     */
    public function testGet($variable, $value)
    {
        $this->storageMock
            ->expects($spy = self::once())
            ->method('get')->with($variable)
            ->willReturn($value)
        ;

        self::assertEquals($value, Session::get($variable));
        /** @var PHPUnit_Framework_MockObject_Invocation_Object $invocation */
        $invocation = $spy->getInvocations()[0];
        self::assertEquals($variable, $invocation->parameters[0]);
    }

    /**
     * @return array
     */
    public function getDataProvider()
    {
        // args: [variable name to ::get, returned value]
        return [
            ['var1', true],
            ['var2', false],
{'fraction_non_alphanumeric': 0.15883615549725733, 'fraction_numerical': 0.00333889816360601, 'mean_word_length': 2.231124807395994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '1438923', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1119, 'n_words': 215}