File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -43,14 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
4343 $ builder ->add (
4444 'lineReference ' ,
4545 HiddenType::class,
46- [
47- 'data ' => (string )$ lineReference ,
48- 'setter ' => static function (Comment $ comment , string $ value ): void {
49- $ lineReference = LineReference::fromString ($ value );
50- $ comment ->setLineReference ($ lineReference );
51- $ comment ->setFilePath (Assert::notNull ($ lineReference ->oldPath ?? $ lineReference ->newPath ));
52- },
53- ]
46+ ['data ' => (string )$ lineReference , 'setter ' => $ this ->setter (...)]
5447 );
5548 $ builder ->add (
5649 'message ' ,
@@ -63,4 +56,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6356 $ builder ->add ('tag ' , CommentTagType::class);
6457 $ builder ->add ('save ' , SubmitType::class, ['label ' => 'add.comment ' ]);
6558 }
59+
60+ public function setter (Comment $ comment , string $ value ): void
61+ {
62+ $ lineReference = LineReference::fromString ($ value );
63+ $ comment ->setLineReference ($ lineReference );
64+ $ comment ->setFilePath (Assert::notNull ($ lineReference ->oldPath ?? $ lineReference ->newPath ));
65+ }
6666}
Original file line number Diff line number Diff line change 55
66use DR \Review \Controller \App \Review \Comment \AddCommentController ;
77use DR \Review \Entity \Review \CodeReview ;
8+ use DR \Review \Entity \Review \Comment ;
89use DR \Review \Entity \Review \LineReference ;
910use DR \Review \Form \Review \AddCommentFormType ;
1011use DR \Review \Form \Review \CommentTagType ;
@@ -74,4 +75,13 @@ public function testBuildForm(): void
7475
7576 $ this ->type ->buildForm ($ builder , ['review ' => $ review , 'lineReference ' => $ lineReference ]);
7677 }
78+
79+ public function testSetter (): void
80+ {
81+ $ reference = 'old/path:new/path:1:2:3:commitSha:A ' ;
82+ $ comment = new Comment ();
83+ $ this ->type ->setter ($ comment , $ reference );
84+ static ::assertEquals (LineReference::fromString ($ reference ), $ comment ->getLineReference ());
85+ static ::assertSame ('old/path ' , $ comment ->getFilePath ());
86+ }
7787}
You can’t perform that action at this time.
0 commit comments