Example #1
0
 function it_also_validates_object(Object $object, ObjectValidator $objectValidator, File $model)
 {
     $violationCollection = new ViolationCollection();
     $model->getStructure()->willReturn($object);
     $objectValidator->validate($object)->willReturn($violationCollection);
     $this->validate($model);
 }
 function it_inserts_the_generated_method(CodeEditor $codeEditor, File $file, FileModel $fileModel, FullyQualifiedNameModel $fullyQualifiedNameModel, MethodModel $methodModel, ObjectModel $objectModel)
 {
     $insertUseStatements = Argument::type(InsertUseStatements::class);
     $insertMethod = Argument::type(InsertMethod::class);
     $generatedMethod = new GeneratedMethod($fileModel->getWrappedObject());
     $fileModel->allFullyQualifiedNames()->willReturn([$fullyQualifiedNameModel]);
     $fileModel->getFilename()->willReturn(self::FILE_NAME);
     $fileModel->getStructure()->willReturn($objectModel);
     $objectModel->allMethods()->willReturn([$methodModel]);
     $codeEditor->open(self::FILE_NAME)->willReturn($file);
     $codeEditor->handle($insertUseStatements)->shouldBeCalled();
     $codeEditor->handle($insertMethod)->shouldBeCalled();
     $codeEditor->save($file)->shouldBeCalled();
     $this->onGeneratedMethod($generatedMethod);
 }
    function it_logs_the_generated_method(File $file, ConsoleIO $io, Method $method, Object $object)
    {
        $generatedMethod = new GeneratedMethod($file->getWrappedObject());
        $file->getStructure()->willReturn($object);
        $object->getName()->willReturn(self::CLASS_NAME);
        $object->allMethods()->willReturn([$method]);
        $method->getName()->willReturn(self::METHOD_NAME);
        $className = self::CLASS_NAME;
        $methodName = self::METHOD_NAME;
        $io->write(<<<OUTPUT

  <info>Generated <value>{$className}#{$methodName}</value></info>

OUTPUT
)->shouldBeCalled();
        $this->onGeneratedMethod($generatedMethod);
    }
    function it_logs_the_generated_constructor(File $file, ConsoleIO $io, Method $method, Object $object, Property $property)
    {
        $generatedConstructor = new GeneratedConstructor($file->getWrappedObject());
        $file->getStructure()->willReturn($object);
        $object->getName()->willReturn(self::CLASS_NAME);
        $object->allProperties()->willReturn([$property]);
        $object->allMethods()->willReturn([$method]);
        $method->getName()->willReturn(self::METHOD_NAME);
        $className = self::CLASS_NAME;
        $methodName = self::METHOD_NAME;
        $propertiesCount = self::PROPERTIES_COUNT;
        $io->write(<<<OUTPUT

  <info>Generated <value>{$propertiesCount}</value> property for <value>{$className}</value>, with its constructor</info>

OUTPUT
)->shouldBeCalled();
        $this->onGeneratedConstructor($generatedConstructor);
    }