コード例 #1
0
 public function testInvalidCharset()
 {
     $this->markTestSkipped('Skipped because of weird behavior on some platforms');
     $db = Propel::getServiceContainer()->getAdapter(BookPeer::DATABASE_NAME);
     if ($db instanceof SqliteAdapter) {
         $this->markTestSkipped();
     }
     $a = new Author();
     $a->setFirstName("Б.");
     $a->setLastName("АКУНИН");
     $a->save();
     $authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName());
     $a->setLastName($authorNameWindows1251);
     // Different databases seem to handle invalid data differently (no surprise, I guess...)
     if ($db instanceof PgsqlAdapter) {
         try {
             $a->save();
             $this->fail("Expected an exception when saving non-UTF8 data to database.");
         } catch (Exception $x) {
             print $x;
         }
     } else {
         // No exception is thrown by MySQL ... (others need to be tested still)
         $a->save();
         $a->reload();
         $this->assertEquals("", $a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)");
     }
 }
コード例 #2
0
 public function testSymfonyFormManyToOne()
 {
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     // We create a simple book and a simple Author and simply link them to each other before reloading them
     $book = new Book();
     $book->setISBN('012345');
     $book->setTitle('Propel Book');
     $author = new Author();
     $author->setFirstName('François');
     $author->setLastName('Z');
     $author->addBook($book);
     $author->save();
     $book->save();
     $author->reload(true);
     $book->reload(true);
     // Symfony is cloning the book object in a ManyToOne form with by_reference = false
     $book2 = clone $book;
     $author->removeBook($book);
     $author->addBook($book2);
     $author->save();
     $author->reload(true);
     $books = $author->getBooks();
     $this->assertCount(1, $books);
 }