<?php

namespace Tests\Unit\Framework;

use Openguru\OpenCartFramework\Support\Str;
use PHPUnit\Framework\TestCase;

class StrTest extends TestCase
{
    public function testStartsWithSingleNeedle(): void
    {
        $this->assertTrue(Str::startsWith('hello world', 'hello'));
        $this->assertTrue(Str::startsWith('test string', 'test'));
        $this->assertFalse(Str::startsWith('hello world', 'world'));
        $this->assertFalse(Str::startsWith('hello world', 'foo'));
    }

    public function testStartsWithEmptyHaystack(): void
    {
        $this->assertFalse(Str::startsWith('', 'hello'));
        $this->assertTrue(Str::startsWith('', ''));
    }

    public function testStartsWithEmptyNeedle(): void
    {
        $this->assertFalse(Str::startsWith('hello', ''));
    }

    public function testStartsWithMultipleNeedles(): void
    {
        $this->assertTrue(Str::startsWith('hello world', ['hello', 'foo']));
        $this->assertTrue(Str::startsWith('test string', ['foo', 'test']));
        $this->assertFalse(Str::startsWith('hello world', ['foo', 'bar']));
    }

    public function testStartsWithCaseSensitive(): void
    {
        $this->assertTrue(Str::startsWith('Hello World', 'Hello'));
        $this->assertFalse(Str::startsWith('Hello World', 'hello'));
        $this->assertFalse(Str::startsWith('hello world', 'Hello'));
    }

    public function testStartsWithExactMatch(): void
    {
        $this->assertTrue(Str::startsWith('test', 'test'));
    }

    public function testStartsWithLongNeedle(): void
    {
        $this->assertTrue(Str::startsWith('short', 'short'));
        $this->assertFalse(Str::startsWith('short', 'short text'));
    }
}


