function it_is_not_fine_with_abstract_methods_with_body(Method $method) { $method->isAbstract()->willReturn(true); $method->getBody()->willReturn(''); $method->getName()->willReturn('__construct'); $this->validate($method)->shouldHaveType('Memio\\Validator\\Violation\\SomeViolation'); }
function it_is_not_fine_with_abstract_and_private_methods(Method $method) { $method->isAbstract()->willReturn(true); $method->getVisibility()->willReturn('private'); $method->getName()->willReturn('__construct'); $this->validate($method)->shouldHaveType('Memio\\Validator\\Violation\\SomeViolation'); }
function it_is_not_fine_none_pure_virtual_methods(Contract $contract, Method $method) { $contract->getName()->willReturn('HttpKernelInterface'); $contract->allMethods()->willReturn(array($method)); $method->getBody()->willReturn('echo "Nobody expects the spanish inquisition";'); $method->getName()->willReturn('handle'); $this->validate($contract)->shouldHaveType('Memio\\Validator\\Violation\\SomeViolation'); }
function it_is_not_fine_with_protected_methods(Contract $contract, Method $method) { $contract->getName()->willReturn('HttpKernelInterface'); $contract->allMethods()->willReturn(array($method)); $method->getVisibility()->willReturn('protected'); $method->getName()->willReturn('handle'); $this->validate($contract)->shouldHaveType('Memio\\Validator\\Violation\\SomeViolation'); }
function it_is_not_fine_with_concrete_object_and_abstract_methods(Object $object, Method $method) { $object->getName()->willReturn('ConcreteClass'); $object->isAbstract()->willReturn(false); $object->allMethods()->willReturn(array($method)); $method->isAbstract()->willReturn(true); $method->getName()->willReturn('abstractClass'); $this->validate($object)->shouldHaveType('Memio\\Validator\\Violation\\SomeViolation'); }
function it_inserts_method_in_class_with_stuff(Editor $editor, File $file, Method $method, PrettyPrinter $prettyPrinter) { $insertMethod = new InsertMethod($file->getWrappedObject(), $method->getWrappedObject()); $method->getName()->willReturn(self::METHOD_NAME); $editor->hasBelow($file, self::METHOD_PATTERN, 0)->willReturn(false); $editor->jumpBelow($file, InsertMethodHandler::CLASS_ENDING, 0)->shouldBeCalled(); $file->decrementCurrentLineNumber(1)->shouldBeCalled(); $file->getLine()->willReturn(' }'); $editor->insertBelow($file, '')->shouldBeCalled(); $prettyPrinter->generateCode($method)->willReturn(self::GENERATED_CODE); $editor->insertBelow($file, self::GENERATED_CODE)->shouldBeCalled(); $this->handle($insertMethod); }
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); }