当前位置: 首页>>代码示例>>PHP>>正文


PHP TestCase::assertTrue方法代码示例

本文整理汇总了PHP中TestCase::assertTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCase::assertTrue方法的具体用法?PHP TestCase::assertTrue怎么用?PHP TestCase::assertTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase的用法示例。


在下文中一共展示了TestCase::assertTrue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fillDB

 /**
  * @param TestCase $test
  * @return DBTestCreator
  */
 public function fillDB(TestCase $test = null)
 {
     $moscow = TestCity::create()->setName('Moscow');
     $piter = TestCity::create()->setName('Saint-Peterburg');
     $mysqler = TestUser::create()->setCity($moscow)->setCredentials(Credentials::create()->setNickname('mysqler')->setPassword(sha1('mysqler')))->setLastLogin(Timestamp::create(time()))->setRegistered(Timestamp::create(time())->modify('-1 day'));
     $postgreser = clone $mysqler;
     $postgreser->setCredentials(Credentials::create()->setNickName('postgreser')->setPassword(sha1('postgreser')))->setCity($piter)->setUrl(HttpUrl::create()->parse('http://postgresql.org/'));
     $piter = TestCity::dao()->add($piter);
     $moscow = TestCity::dao()->add($moscow);
     if ($test) {
         $test->assertEquals($piter->getId(), 1);
         $test->assertEquals($moscow->getId(), 2);
     }
     $postgreser = TestUser::dao()->add($postgreser);
     for ($i = 0; $i < 10; $i++) {
         $encapsulant = TestEncapsulant::dao()->add(TestEncapsulant::create()->setName($i));
         $encapsulant->getCities()->fetch()->setList(array($piter, $moscow))->save();
     }
     $mysqler = TestUser::dao()->add($mysqler);
     if ($test) {
         $test->assertEquals($postgreser->getId(), 1);
         $test->assertEquals($mysqler->getId(), 2);
     }
     if ($test) {
         // put them in cache now
         TestUser::dao()->dropIdentityMap();
         TestUser::dao()->getById(1);
         TestUser::dao()->getById(2);
         if ($test instanceof DBDataTest) {
             $test->getListByIdsTest();
         }
         Cache::me()->clean();
         $test->assertTrue($postgreser == TestUser::dao()->getById(1));
         $test->assertTrue($mysqler == TestUser::dao()->getById(2));
     }
     $firstClone = clone $postgreser;
     $secondClone = clone $mysqler;
     $firstCount = TestUser::dao()->dropById($postgreser->getId());
     $secondCount = TestUser::dao()->dropByIds(array($mysqler->getId()));
     if ($test) {
         $test->assertEquals($firstCount, 1);
         $test->assertEquals($secondCount, 1);
         try {
             TestUser::dao()->getById(1);
             $test->fail();
         } catch (ObjectNotFoundException $e) {
             /* pass */
         }
         $result = Criteria::create(TestUser::dao())->add(Expression::eq(1, 2))->getResult();
         $test->assertEquals($result->getCount(), 0);
         $test->assertEquals($result->getList(), array());
     }
     TestUser::dao()->import($firstClone);
     TestUser::dao()->import($secondClone);
     if ($test && $test instanceof DBDataTest) {
         // cache multi-get
         $test->getListByIdsTest();
         $test->getListByIdsTest();
     }
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:65,代码来源:DBTestCreator.class.php

示例2: RunnableTest

        </style>
    </head>
    <body>
        <h1>Simple test script for simple test</h1>
        <ol>
            <?php 
// Abstract class test.
//
$runnable = new RunnableTest("Me");
assertion("Me" == $runnable->getLabel(), "Expected [Me] got [" . $runnable->getLabel() . "]");
$test_case = new TestCase();
$test_case->attachObserver(new TestOfTestReporter(array(null), array(true), array("stuff")));
$test_case->assertTrue(true, "stuff");
$test_case = new TestCase();
$test_case->attachObserver(new TestOfTestReporter(array(null), array(false), array("more stuff")));
$test_case->assertTrue(false, "more stuff");
// Testing group test with reporter.
//
$test = new GroupTest("Me again");
assertion("Me again" == $test->getLabel(), "Expected [Me again] got [" . $test->getLabel() . "]");
$test->attachObserver(new TestOfTestReporter(array("Me again", "Me again"), array(null, null), array(null, null)));
$test->run();
// Build a test case.
//
class MyTestCase extends TestCase
{
    var $test_variable;
    function MyTestCase()
    {
        $this->TestCase();
    }
开发者ID:sebs,项目名称:simpletest,代码行数:31,代码来源:simple_test_test.php


注:本文中的TestCase::assertTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。