function it_inserts_property_in_class_with_methods(Editor $editor, File $file, PrettyPrinter $prettyPrinter, Property $property) { $insertProperty = new InsertProperty($file->getWrappedObject(), $property->getWrappedObject()); $property->getName()->willReturn('property'); $editor->hasBelow($file, '/^ private \\$property;$/', 0)->willReturn(false); $editor->hasBelow($file, InsertPropertyHandler::PROPERTY, 0)->willReturn(false); $editor->hasBelow($file, InsertPropertyHandler::CONSTANT, 0)->willReturn(false); $editor->jumpBelow($file, InsertPropertyHandler::CLASS_OPENING, 0)->shouldBeCalled(); $prettyPrinter->generateCode($property)->willReturn(' private $property;'); $editor->insertBelow($file, ' private $property;')->shouldBeCalled(); $file->incrementCurrentLineNumber(1)->shouldBeCalled(); $file->getLine()->willReturn(' public function __construct($property)'); $editor->insertAbove($file, '')->shouldBeCalled(); $this->handle($insertProperty); }