/** * Configures a Comment form. * * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['add_author']) { $builder->add('authorName', 'text', array('required' => true)); $this->vars['add_author'] = $options['add_author']; } if ($options['show_note']) { $builder->add('note', 'choice', array('required' => false, 'choices' => $this->noteProvider->getValues())); } $builder->add('website', 'url', array('required' => false))->add('email', 'email', array('required' => false)); }
/** * Test getValues() method */ public function testGetValues() { // Given $thread = $this->getMock('Sonata\\CommentBundle\\Model\\Thread'); $commentManager = $this->getMockBuilder('Sonata\\CommentBundle\\Manager\\CommentManager')->disableOriginalConstructor()->getMock(); $provider = new NoteProvider($commentManager, array(1, 2, 3)); // When $notes = $provider->getValues(); // Then $this->assertEquals(array(1, 2, 3), $notes, 'Should return notes given in constructor'); }