mercredi 31 mai 2017

Testing arguments of the method tested

is it possible or good idea to test arguments of the class that has the method mocked ? Example :

class CarType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {

        $builder->addEventSubscriber(new User('argument example')

    }
}

This is my test:

    public function testFormBuilder()
    {

    $builder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')
        ->disableOriginalConstructor()
        ->getMock();

       // Test    
        $type = new CarType();

            $this->builder->expects($this->once())
                ->method('addEventSubscriber')
                ->with(
                    $this->isInstanceOf(User::class)
                );

            $type->buildForm($this->builder, []);


    }

This test work fine, But... I want to know if the first argument of the User class is a string, but can I do in this same test?

Aucun commentaire:

Enregistrer un commentaire