示例#1
0
 public function testUtf8()
 {
     $this->markTestSkipped('Skipped because of weird behavior on some platforms');
     $db = Propel::getServiceContainer()->getAdapter(BookPeer::DATABASE_NAME);
     $title = "Смерть на брудершафт. Младенец и черт";
     //        1234567890123456789012345678901234567
     //                 1         2         3
     $a = new Author();
     $a->setFirstName("Б.");
     $a->setLastName("АКУНИН");
     $p = new Publisher();
     $p->setName("Детектив российский, остросюжетная проза");
     $b = new Book();
     $b->setTitle($title);
     $b->setISBN("B-59246");
     $b->setAuthor($a);
     $b->setPublisher($p);
     $b->save();
     $b->reload();
     $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title.");
     $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title.");
 }
示例#2
0
 /**
  * Tests the Base[Object]::setByName() method
  */
 public function testSetByName()
 {
     $book = new Book();
     $types = array(BasePeer::TYPE_PHPNAME => 'Title', BasePeer::TYPE_STUDLYPHPNAME => 'title', BasePeer::TYPE_COLNAME => 'book.TITLE', BasePeer::TYPE_FIELDNAME => 'title', BasePeer::TYPE_NUM => 1);
     $title = 'Harry Potter and the Order of the Phoenix';
     foreach ($types as $type => $name) {
         $book->setByName($name, $title, $type);
         $result = $book->getTitle();
         $this->assertEquals($title, $result);
     }
 }
 public function testFormatALotOfResults()
 {
     $nbBooks = 50;
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     Propel::disableInstancePooling();
     $book = new Book();
     for ($i = 0; $i < $nbBooks; $i++) {
         $book->clear();
         $book->setTitle('BookTest' . $i);
         $book->setISBN('FA404-' . $i);
         $book->save($con);
     }
     $stmt = $con->query('SELECT * FROM book');
     $formatter = new OnDemandFormatter();
     $formatter->init(new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book'));
     $books = $formatter->format($stmt);
     $this->assertTrue($books instanceof OnDemandCollection, 'OnDemandFormatter::format() returns a PropelOnDemandCollection');
     $this->assertEquals($nbBooks, count($books), 'OnDemandFormatter::format() returns a collection that counts as many rows as the results in the query');
     $i = 0;
     foreach ($books as $book) {
         $this->assertTrue($book instanceof Book, 'OnDemandFormatter::format() returns a collection of Model objects');
         $this->assertEquals('BookTest' . $i, $book->getTitle(), 'OnDemandFormatter::format() returns the model objects matching the query');
         $i++;
     }
     Propel::enableInstancePooling();
 }
示例#4
0
 /**
  * Tests the Base[Object]::setByName() method
  */
 public function testSetByName()
 {
     $book = new Book();
     $types = [TableMap::TYPE_PHPNAME => 'Title', TableMap::TYPE_CAMELNAME => 'title', TableMap::TYPE_COLNAME => 'book.title', TableMap::TYPE_FIELDNAME => 'title', TableMap::TYPE_NUM => 1];
     $title = 'Harry Potter and the Order of the Phoenix';
     foreach ($types as $type => $name) {
         $book->setByName($name, $title, $type);
         $result = $book->getTitle();
         $this->assertEquals($title, $result);
     }
 }