<commit_before><?php

namespace Illuminate\Tests\Support;

use Illuminate\Support\Traits\Tappable;
use PHPUnit\Framework\TestCase;

class SupportTappableTest extends TestCase
{
    public function testTappableClassWithCallback()
    {
        $name = TappableClass::make()->tap(function ($tappable) {
            $tappable->setName('MyName');
        })->getName();

        $this->assertSame('MyName', $name);
    }

    public function testTappableClassWithoutCallback()
    {
        $name = TappableClass::make()->tap()->setName('MyName')->getName();

        $this->assertSame('MyName', $name);
    }<commit_msg>[8.x] Add regression tests on using Tappable with invokable class (#37577)<commit_after><?php

namespace Illuminate\Tests\Support;

use Illuminate\Support\Traits\Tappable;
use PHPUnit\Framework\TestCase;

class SupportTappableTest extends TestCase
{
    public function testTappableClassWithCallback()
    {
        $name = TappableClass::make()->tap(function ($tappable) {
            $tappable->setName('MyName');
        })->getName();

        $this->assertSame('MyName', $name);
    }

    public function testTappableClassWithInvokableClass()
    {
        $name = TappableClass::make()->tap(new class
        {
            public function __invoke($tappable)
            {
                $tappable->setName('MyName');
            }
        })->getName();

        $this->assertSame('MyName', $name);
    }

    public function testTappableClassWithNoneInvokableClass()
    {
        $this->expectException('Error');

        $name = TappableClass::make()->tap(new class
        {
            public function setName($tappable)
            {
                $tappable->setName('MyName');
            }
        })->getName();

        $this->assertSame('MyName', $name);
    }

    public function testTappableClassWithoutCallback()
    {
        $name = TappableClass::make()->tap()->setName('MyName')->getName();

        $this->assertSame('MyName', $name);
    }
{'fraction_non_alphanumeric': 0.1448692152917505, 'fraction_numerical': 0.0030181086519114686, 'mean_word_length': 2.7599243856332705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2476883', 'n_tokens_mistral': 597, 'n_tokens_neox': 579, 'n_words': 93}