<?php

namespace Core\Utils;

use PHPUnit\Framework\TestCase;

class ArrayUtilsTest extends TestCase
{
    public function testFind()
    {
        $arr = [
            'test.*.*',
            'test.*',
            'test',
            'test\\one.*',
            'test\\two.*'
        ];

        $this->assertEquals('test', ArrayUtils::find($arr, 'test'));
        $this->assertEquals('test.*', ArrayUtils::find($arr, 'test.some'));
        $this->assertEquals('test.*.*', ArrayUtils::find($arr, 'test.some.other'));

        $this->assertEquals('test\\one.*', ArrayUtils::find($arr, 'test\\one.some'));
        $this->assertEquals('test\\two.*', ArrayUtils::find($arr, 'test\\two.other'));
        $this->assertEquals(false, ArrayUtils::find($arr, 'not'));
        $this->assertEquals(false, ArrayUtils::find($arr, 'not.*'));
        $this->assertEquals(false, ArrayUtils::find($arr, '*.not'));
    }
}

<?php

namespace Core\Utils;

use PHPUnit\Framework\TestCase;

class ArrayUtilsTest extends TestCase
{
    public function testFind1()
    {
        $arr = [
            'test.*.*',
            'test.*',
            'test',
            'test\\one.*',
            'test\\two.*'
        ];

        $this->assertEquals('test', ArrayUtils::find($arr, 'test'));
        $this->assertEquals('test.*', ArrayUtils::find($arr, 'test.some'));
        $this->assertEquals('test.*.*', ArrayUtils::find($arr, 'test.some.other'));

        $this->assertEquals('test\\one.*', ArrayUtils::find($arr, 'test\\one.some'));
        $this->assertEquals('test\\two.*', ArrayUtils::find($arr, 'test\\two.other'));

        $this->assertEquals(false, ArrayUtils::find($arr, 'not'));
        $this->assertEquals(false, ArrayUtils::find($arr, 'not.*'));
        $this->assertEquals(false, ArrayUtils::find($arr, '*.not'));
    }

    public function testFind2()
    {
        $arr = [
            'test',
            'test.some',
            'test.some.other',
            'test\\one.some',
            'test\\two.other'
        ];

        $this->assertEquals('test', ArrayUtils::find($arr, 'test'));
        $this->assertEquals('test.some', ArrayUtils::find($arr, 'test.*'));
        $this->assertEquals('test.some.other', ArrayUtils::find($arr, 'test.*.*'));

        $this->assertEquals('test\\one.some', ArrayUtils::find($arr, 'test\\one.*'));
        $this->assertEquals('test\\two.other', ArrayUtils::find($arr, 'test\\two.*'));

        $this->assertEquals(false, ArrayUtils::find($arr, 'not'));
        $this->assertEquals(false, ArrayUtils::find($arr, 'not.*'));
        $this->assertEquals(false, ArrayUtils::find($arr, '*.not'));
    }
}

Add a unit test of ArrayUtils when reverse matching
Add a unit test of ArrayUtils when reverse matching
