當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Author::setAge方法代碼示例

本文整理匯總了PHP中Propel\Tests\Bookstore\Author::setAge方法的典型用法代碼示例。如果您正苦於以下問題:PHP Author::setAge方法的具體用法?PHP Author::setAge怎麽用?PHP Author::setAge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Tests\Bookstore\Author的用法示例。


在下文中一共展示了Author::setAge方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testIsModifiedAndNullValues

 public function testIsModifiedAndNullValues()
 {
     $a = new Author();
     $a->setFirstName('');
     $a->setLastName('Bar');
     $a->setAge(0);
     $a->save();
     $a->setFirstName(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL.");
     $a->setAge(null);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL.");
     $a->setFirstName('');
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column value to empty string.");
     $a->setAge(0);
     $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column to 0-value int.");
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:16,代碼來源:GeneratedObjectTest.php

示例2: testScenarioUsingQuery


//.........這裏部分代碼省略.........
     $el = array_shift($failures);
     $this->assertContains("must be more than", $el->getMessage(), 'Expected validation message was returned');
     $bk2 = new Book();
     $bk2->setTitle("Don Juan");
     $ret = $bk2->validate();
     $this->assertFalse($ret, 'validation failed');
     $failures = $bk2->getValidationFailures();
     $this->assertEquals(1, count($failures), '1 validation message was returned');
     $el = array_shift($failures);
     $this->assertContains("Book title already in database.", $el->getMessage(), 'Expected validation message was returned');
     //Now trying some more complex validation.
     $auth1 = new Author();
     $auth1->setFirstName("Hans");
     // last name required; will fail
     $bk1->setAuthor($auth1);
     $rev1 = new Review();
     $rev1->setReviewDate("08/09/2001");
     // will fail: reviewed_by column required
     $bk1->addReview($rev1);
     $ret2 = $bk1->validate();
     $this->assertFalse($ret2, 'validation failed');
     $failures2 = $bk1->getValidationFailures();
     $this->assertEquals(3, count($failures2), '3 validation messages were returned');
     $expectedKeys = array(AuthorPeer::LAST_NAME, BookPeer::TITLE, ReviewPeer::REVIEWED_BY);
     $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed');
     $bk2 = new Book();
     $bk2->setTitle("12345678901");
     // passes
     $auth2 = new Author();
     $auth2->setLastName("Blah");
     //passes
     $auth2->setEmail("some@body.com");
     //passes
     $auth2->setAge(50);
     //passes
     $bk2->setAuthor($auth2);
     $rev2 = new Review();
     $rev2->setReviewedBy("Me!");
     // passes
     $rev2->setStatus("new");
     // passes
     $bk2->addReview($rev2);
     $ret3 = $bk2->validate();
     $this->assertTrue($ret3, 'complex validation can pass');
     // Testing doCount() functionality
     // -------------------------------
     // old way
     $c = new Criteria();
     $records = BookPeer::doSelect($c);
     $count = BookPeer::doCount($c);
     $this->assertEquals($count, count($records), 'correct number of results');
     // new way
     $count = BookQuery::create()->count();
     $this->assertEquals($count, count($records), 'correct number of results');
     // Test many-to-many relationships
     // ---------------
     // init book club list 1 with 2 books
     $blc1 = new BookClubList();
     $blc1->setGroupLeader("Crazyleggs");
     $blc1->setTheme("Happiness");
     $brel1 = new BookListRel();
     $brel1->setBook($phoenix);
     $brel2 = new BookListRel();
     $brel2->setBook($dj);
     $blc1->addBookListRel($brel1);
     $blc1->addBookListRel($brel2);
開發者ID:norfil,項目名稱:Propel2,代碼行數:67,代碼來源:BookstoreTest.php

示例3: testDoValidate_Nulls

 /**
  * Test the fact that validators should not complain NULL values for non-required columns.
  */
 public function testDoValidate_Nulls()
 {
     $author = new Author();
     $author->setFirstName("Malcolm");
     // last name required, valid email format, age > 0
     $author->setLastName("X");
     $author->setEmail(null);
     // just to be explicit, of course these are the defaults anyway
     $author->setAge(null);
     $res = $author->validate();
     $this->assertTrue($res, "Expected validation to pass with NULL columns");
     $author->setEmail('malcolm@');
     // fail
     $res = $author->validate();
     $this->assertFalse($res, "Expected validation to fail.");
     $failures = $author->getValidationFailures();
     $this->assertEquals(1, count($failures), "Expected 1 column to fail validation.");
     $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation.");
 }
開發者ID:norfil,項目名稱:Propel2,代碼行數:22,代碼來源:ValidatorTest.php


注:本文中的Propel\Tests\Bookstore\Author::setAge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。