<?php

namespace App\Tests\Unit\Service\OnChange;

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

class OnChangeDefaultTest extends TestCase
{
    /**
     * Default OnChange service does nothing; it shouldn't change anything to the data nor raise exceptions
     *
     * @see OnChangeDefault::validate()
     * @see OnChangeDefault::preProcess()
     * @see OnChangeDefault::beforeChange()
     * @see OnChangeDefault::onChange()
     */
    public function testDoesNothing(): void
    {
        $data = 1;

        $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();

        $onChange = new OnChangeDefault();
        $onChange->validate($data, $context);
        $data = $onChange->preProcess($data, $context);
        $onChange->beforeChange($data, $context);
        $onChange->onChange($data, $context);

        $this->assertEquals(1, $data);
    }
}
