MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/help.cafsindia.com/vendor/intervention/imagecache/tests/HashableClosureTest.php
<?php

namespace Intervention\Image\Test;

use Intervention\Image\HashableClosure;
use Opis\Closure\SerializableClosure;
use PHPUnit\Framework\TestCase;

class HashableClosureTest extends TestCase
{
    public function testConstructor()
    {
        $hashable = new HashableClosure(function () {
            return 'foo';
        });

        $this->assertInstanceOf(HashableClosure::class, $hashable);
    }

    public function testSetGetClosure()
    {
        $hashable = new HashableClosure(function () {
            return 'foo';
        });

        $result = $hashable->setClosure(function () {
            return 'bar';
        });

        $this->assertInstanceOf(HashableClosure::class, $result);
        $this->assertInstanceOf(SerializableClosure::class, $hashable->getClosure());
    }

    public function testGetHash()
    {
        $hashable1 = new HashableClosure(function ($test) {
            $test->set('foo');
            $test->test(30);
        });
        $hashable2 = new HashableClosure(function ($test) {
            $test->set('foo');
            $test->test(30);
        });
        $hashable3 = new HashableClosure(function ($test) {
            $test->set('foo');
            $test->test(31);
        });

        $this->assertEquals($hashable1->getHash(), $hashable2->getHash());
        $this->assertNotEquals($hashable1->getHash(), $hashable3->getHash());
        $this->assertNotEquals($hashable2->getHash(), $hashable3->getHash());
    }
}