HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: /virtual/nagasaki/public_html/ec/vendor/silex/silex/tests/Silex/Tests/CallbackResolverTest.php
<?php

/*
 * This file is part of the Silex framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Silex\Tests;

use Silex\CallbackResolver;

class CallbackResolverTest extends \PHPUnit_Framework_Testcase
{
    private $app;
    private $resolver;

    public function setup()
    {
        $this->app = new \Pimple();
        $this->resolver = new CallbackResolver($this->app);
    }

    public function testShouldResolveCallback()
    {
        $this->app['some_service'] = function () { return new \stdClass(); };

        $this->assertTrue($this->resolver->isValid('some_service:methodName'));
        $this->assertEquals(
            array($this->app['some_service'], 'methodName'),
            $this->resolver->convertCallback('some_service:methodName')
        );
    }

    public function testNonStringsAreNotValid()
    {
        $this->assertFalse($this->resolver->isValid(null));
        $this->assertFalse($this->resolver->isValid('some_service::methodName'));
    }

    /**
     * @expectedException          \InvalidArgumentException
     * @expectedExceptionMessage   Service "some_service" does not exist.
     */
    public function testShouldThrowAnExceptionIfServiceIsMissing()
    {
        $this->resolver->convertCallback('some_service:methodName');
    }
}