removeMethodCall example

// if both mask base with extended extended as base             if (isset($definitions['extended']$definitions['base'])) {
                $container->setAlias(self::PREFIX . $definitions['base']new Alias($definitions['extended'], true));
            }

            // if base only clone definition             if (!isset($definitions['extended']) && isset($definitions['base'])) {
                $service = $container->getDefinition($definitions['base']);

                $clone = clone $service;
                $clone->removeMethodCall('compile');
                $clone->clearTags();
                $container->setDefinition(self::PREFIX . $definitions['base']$clone);
                $this->setUpEntityDefinitionService($container, self::PREFIX . $definitions['base']);

                $entityNameMap[$entityName] = $definitions['base'];

                if (isset($definitions['alias'])) {
                    $entityNameMap[$definitions['alias']] = $definitions['base'];
                }
            }
        }

        
public function testMethodCalls()
    {
        $def = new Definition('stdClass');
        $this->assertSame($def$def->setMethodCalls([['foo', ['foo']]]), '->setMethodCalls() implements a fluent interface');
        $this->assertEquals([['foo', ['foo']]]$def->getMethodCalls(), '->getMethodCalls() returns the methods to call');
        $this->assertSame($def$def->addMethodCall('bar', ['bar']), '->addMethodCall() implements a fluent interface');
        $this->assertEquals([['foo', ['foo']]['bar', ['bar']]]$def->getMethodCalls(), '->addMethodCall() adds a method to call');
        $this->assertSame($def$def->addMethodCall('foobar', ['foobar'], true), '->addMethodCall() implements a fluent interface with third parameter');
        $this->assertEquals([['foo', ['foo']]['bar', ['bar']]['foobar', ['foobar'], true]]$def->getMethodCalls(), '->addMethodCall() adds a method to call');
        $this->assertTrue($def->hasMethodCall('bar'), '->hasMethodCall() returns true if first argument is a method to call registered');
        $this->assertFalse($def->hasMethodCall('no_registered'), '->hasMethodCall() returns false if first argument is not a method to call registered');
        $this->assertSame($def$def->removeMethodCall('bar'), '->removeMethodCall() implements a fluent interface');
        $this->assertTrue($def->hasMethodCall('foobar'), '->hasMethodCall() returns true if first argument is a method to call registered');
        $this->assertSame($def$def->removeMethodCall('foobar'), '->removeMethodCall() implements a fluent interface');
        $this->assertEquals([['foo', ['foo']]]$def->getMethodCalls(), '->removeMethodCall() removes a method to call');
        $this->assertSame($def$def->setMethodCalls([['foobar', ['foobar'], true]]), '->setMethodCalls() implements a fluent interface with third parameter');
        $this->assertEquals([['foobar', ['foobar'], true]]$def->getMethodCalls(), '->addMethodCall() adds a method to call');
    }

    public function testExceptionOnEmptyMethodCall()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('Method name cannot be empty.');
        
Home | Imprint | This part of the site doesn't use cookies.