<?php

namespace App\Tests\Unit\Service\OnChange;

use App\Service\OnChange\OnChangeContext;
use PHPUnit\Framework\TestCase;

class OnChangeContextTest extends TestCase
{
    /**
     * @see OnChangeContext::__construct()
     * @see OnChangeContext::isPostRequest()
     * @see OnChangeContext::isPutRequest()
     */
    public function testIsPostRequest(): void
    {
        $context = new OnChangeContext(
            ['collection_operation_name' => 'post']
        );

        $this->assertTrue($context->isPostRequest());
        $this->assertFalse($context->isPutRequest());
    }

    /**
     * @see OnChangeContext::__construct()
     * @see OnChangeContext::isPostRequest()
     * @see OnChangeContext::isPutRequest()
     */
    public function testIsPutRequest(): void
    {
        $context = new OnChangeContext(
            ['item_operation_name' => 'put']
        );

        $this->assertTrue($context->isPutRequest());
        $this->assertFalse($context->isPostRequest());
    }

    /**
     * @see OnChangeContext::previousData()
     */
    public function testPreviousData(): void
    {
        $context = new OnChangeContext(
            ['previous_data' => 1]
        );

        $this->assertEquals(1, $context->previousData());
    }
}
