setTitle() public method

public setTitle ( string $title )
$title string
Exemplo n.º 1
0
 /**
  * @param string $title
  * @param string $author
  * @param string $isbn
  * @param string $price
  * @dataProvider providerBookData
  */
 public function testGetBookReturnsExpectedBookObject($title, $author, $isbn, $price)
 {
     $book = new Book();
     $book->setTitle($title)->setAuthor($author)->setIsbn($isbn)->setPrice($price);
     $this->assertEquals($book->getTitle(), $title);
     $this->assertEquals($book->getAuthor(), $author);
     $this->assertEquals($book->getISBN(), $isbn);
     $this->assertEquals($book->getPrice(), $price);
 }
Exemplo n.º 2
0
 public function testSubmitValidData()
 {
     $formData = array('title' => 'Test titel', 'author' => 'der unit tester', 'isbn' => '123445', 'price' => '99');
     // test that class BookType compiles
     $form = $this->factory->create(BookType::class);
     $book = new Book();
     $book->setTitle($formData['title'])->setAuthor($formData['author'])->setIsbn($formData['isbn'])->setPrice($formData['price']);
     $form->submit($formData);
     // test that data is correctly transformed by the form
     $this->assertTrue($form->isSynchronized());
     // test that form was submitted and the data mapping is correct
     $this->assertEquals($book, $form->getData());
     // test that all widgets(eg keys from $formData)
     // are available in the children property
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }