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


PHP PHPUnit_Framework_TestCase::assertTrue方法代码示例

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


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

示例1: assertDbQuery

 public function assertDbQuery($sqlPart, $message = null)
 {
     $queryProfiles = $this->_profiler->getQueryProfiles();
     $this->_test->assertTrue(is_array($queryProfiles), "No database queries were made.");
     $ranQuery = false;
     if (is_array($sqlPart)) {
         $query = $sqlPart[0];
         $params = $sqlPart[1];
     } else {
         $query = $sqlPart;
     }
     foreach ($queryProfiles as $profile) {
         if (strpos($profile->getQuery(), $query) !== false) {
             if (isset($params) && $profile->getQueryParams() == $params) {
                 $ranQuery = true;
                 break;
             } else {
                 if (!isset($params)) {
                     $ranQuery = true;
                     break;
                 }
             }
         }
     }
     $this->_test->assertTrue($ranQuery, $message . PHP_EOL . "Should have run SQL query containing '{$query}'." . (isset($params) ? PHP_EOL . "Should have been passed parameters: " . print_r($params, true) : ''));
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:26,代码来源:DbProfiler.php

示例2: receiveUpdate

 /**
  * {@inheritDoc}
  */
 public function receiveUpdate(SubjectInterface $subject)
 {
     $this->order = self::$counter++;
     $this->subject = $subject;
     if ($this->double) {
         $subject->notifyObservers();
     }
     if ($this->test) {
         $this->test->assertTrue(Property::get($subject, 'updating'), 'The subject should be updating.');
     }
     if ($this->interrupt) {
         $this->reason = new ReasonException('Testing interruption.');
         $subject->interruptUpdate($this->reason);
     }
 }
开发者ID:kornelek,项目名称:lms,代码行数:18,代码来源:Observer.php

示例3: expectedValueIsValid

 /**
  * @test
  */
 public function expectedValueIsValid()
 {
     $enum = $this->getEnumClass();
     foreach ($this->getExpectedValues() as $value) {
         parent::assertTrue($enum::isValid($value));
     }
 }
开发者ID:oqq,项目名称:minc-common,代码行数:10,代码来源:EnumTestCase.php

示例4: check

 public static function check(\PHPUnit_Framework_TestCase $test, SSODescriptor $descriptor, array $expectedNameIdFormats)
 {
     $test->assertCount(count($expectedNameIdFormats), $descriptor->getAllNameIDFormats());
     foreach ($expectedNameIdFormats as $nameIdFormat) {
         $test->assertTrue($descriptor->hasNameIDFormat($nameIdFormat));
     }
 }
开发者ID:aarnaud,项目名称:lightSAML,代码行数:7,代码来源:NameIdFormatChecker.php

示例5: testSignSoapMessage

    public function testSignSoapMessage()
    {
        $expected = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wns1="urn:hello-world:1.0"><SOAP-ENV:Body><wns1:sayHello xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wns1="urn:hello-world:1.0"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></ds:CanonicalizationMethod>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>
  <ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod><ds:DigestValue>QG06QpnB5HBcTxoj9sP4lwgr5fs=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>KbCRtraU6vpqojaPm2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DUjqxUeKU3fft9fGIAZl0dduitC2Otv4dr1gxLrUmI+ZZ75FmtfKQT7SmS92QVI2B5WAPlL1bnbvhkZiyw7nFE+Q/wGJ2myE4RIFjdAgMBAAGjgd4wgdswHQYDVR0OBBYEFEC5iG0uGXLpQG/zMj/4TuDWfTpHMIGrBgNVHSMEgaMwgaCAFEC5iG0uGXLpQG/zMj/4TuDWfTpHoX2kezB5MQswCQYDVQQGEwJVUzEOMAwGA1UECBMFTWFpbmUxEjAQBgNVBAcTCUxpbWluZ3RvbjEfMB0GA1UEChMWeG1sc2VjbGlicy5waHAgTGlicmFyeTElMCMGA1UEAxMceG1sc2VjbGlicy93d3cuY2RhdGF6b25lLm9yZ4IJAPTrkMJbCOr1MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBACmSKrte07VrGB8dtrN5mrt28ILickQjguu46h6vChgQ4YfIAoA1KWNsZJUuuIzTDjE5xz2hsW37CI0yrNesv2ho2hhP+fIaxCGmcwLYXL80UaPRglYk5+wPWFOt3QFAVoEgwjLX9+y+c2Gu7xLgHAFZVRjQ5hhKT0Nj3vhnt0k8LcognNl1wKuWda7VL4tODp/2IOXr5o5v/OL3UesGfeWfvr8LVmMc5f7/vLAu1+2Yk+/C9/EZyf3BDZQ4z8ae/iwqprCTUIEjhUDcq4+0YN2EIw6suGE2FtWlsIywNErmoOhdrmntU61n3nFCQBi7QDUnZrAFrl4/bmk3eRJ00nE=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature></wns1:sayHello></SOAP-ENV:Body></SOAP-ENV:Envelope>
';
        try {
            $this->client->__call('sayHello', []);
        } catch (\Exception $e) {
            // Ignore
        }
        $lastRequest = $this->client->__getLastRequest();
        TestCase::assertEquals($expected, $lastRequest);
        $dom = new DOMDocument();
        $dom->loadXML($lastRequest);
        $body = $dom->getElementsByTagNameNS($dom->documentElement->namespaceURI, 'Body')->item(0);
        $firstElement = $body->firstChild;
        // Check Signature
        $xmlDSigAdapter = $this->client->getXmlDSigAdapter();
        $newData = new DOMDocument();
        $newData->loadXML($firstElement->C14N());
        TestCase::assertTrue($xmlDSigAdapter->verify($newData));
    }
开发者ID:leoclaro,项目名称:xmldsig,代码行数:26,代码来源:SoapClientTest.php

示例6: assertTrue

 public static function assertTrue($condition, $msg = null)
 {
     if ($condition instanceof Net_LDAP2_Error) {
         self::fail('Error: ' . $condition->getMessage());
     }
     return parent::assertTrue($condition, $msg);
 }
开发者ID:gregoryR,项目名称:Net_LDAP2,代码行数:7,代码来源:Net_LDAP2_TestBase.php

示例7: assertJsonResponse

 /**
  * Test API response status
  *
  * @param Response $response
  * @param int    $statusCode
  * @param string $contentType
  */
 public static function assertJsonResponse($response, $statusCode = 201, $contentType = 'application/json')
 {
     \PHPUnit_Framework_TestCase::assertEquals($statusCode, $response->getStatusCode(), $response->getContent());
     if ($contentType !== '') {
         \PHPUnit_Framework_TestCase::assertTrue($response->headers->contains('Content-Type', $contentType), $response->headers);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:14,代码来源:ToolsAPI.php

示例8: doInspect

 public function doInspect()
 {
     $params = $this->getFilterParameter();
     $this->testCase->assertEquals(array('foo', 'bar'), $params->getFields());
     $this->testCase->assertEquals('2014-01-26', $params->getUpdatedSince()->format('Y-m-d'));
     $this->testCase->assertEquals(8, $params->getCount());
     $this->testCase->assertEquals('id', $params->getFilterBy());
     $this->testCase->assertEquals('equals', $params->getFilterOp());
     $this->testCase->assertEquals('12', $params->getFilterValue());
     $this->testCase->assertEquals('id', $params->getSortBy());
     $this->testCase->assertEquals(Sql::SORT_DESC, $params->getSortOrder());
     $this->testCase->assertEquals(4, $params->getStartIndex());
     $condition = FilterParameter::getCondition($params);
     $this->testCase->assertEquals(array(array('id', '=', '12', 'AND', 1), array('date', '>', '2014-01-26 00:00:00', 'AND', 1)), $condition->toArray());
     // check writer
     $this->testCase->assertTrue($this->isWriter('PSX\\Data\\Writer\\Json'));
 }
开发者ID:seytar,项目名称:psx,代码行数:17,代码来源:TestApiController.php

示例9: containsValues

 /**
  * @param array $values
  *
  * @test
  * @dataProvider getInstanceValues
  */
 public function containsValues($values)
 {
     $collection = $this->getCollectionInstance($values);
     parent::assertCount(count($values), $collection);
     foreach ($collection as $value) {
         parent::assertTrue($collection->contains($value));
     }
 }
开发者ID:oqq,项目名称:minc-common,代码行数:14,代码来源:AbstractCollectionTestCase.php

示例10: fail

 /**
  * Overwritten lime_test method
  *
  * @see lime_test#fail()
  */
 public function fail($message = '')
 {
     // $this->testCase->fail could not be called here, otherwise
     // the ugly exception
     // "Exception thrown without a stack frame in Unknown on line 0" will be thrown
     // $this->testCase->fail( $message );
     // @TODO find a solution to be able calling the fail method directly
     $this->testCase->assertTrue(false, 'FAIL: ' . $message);
 }
开发者ID:EasyFinance,项目名称:sfPhpunitPlugin,代码行数:14,代码来源:sfPHPUnitLimeAdapter.php

示例11: elementShouldHaveClass

 /**
  * Checks an element has a class
  *
  * @Then /^"([^"]*)" element should have class "([^"]*)"$/
  *
  * @return void
  */
 public function elementShouldHaveClass($selector, $class)
 {
     $session = $this->getSession();
     $page = $session->getPage();
     $element = $page->find('css', $selector);
     if (!$element) {
         throw new ElementNotFoundException($session, 'Element "' . $selector . '"');
     }
     \PHPUnit_Framework_TestCase::assertTrue($element->hasClass($class));
 }
开发者ID:neemzy,项目名称:patchwork-core,代码行数:17,代码来源:FeatureContext.php

示例12: it_generates_a_status_object

 public function it_generates_a_status_object()
 {
     $config = new Config();
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/models.json');
     $this->config = $config;
     $request = new Request();
     $response = new Response();
     $route = (object) [];
     $this->handleStatusRequest($request, $response, $route)->shouldReturn($this);
     Assertions::assertEquals('application/json', $response->getHeader('Content-Type'), 'should set content type to JSON');
     Assertions::assertEquals('ok', $response->getBody()->status, 'should set status field');
     Assertions::assertTrue(is_int($response->getBody()->timestamp), 'should set timestamp field');
 }
开发者ID:bnowack,项目名称:backbone-php,代码行数:13,代码来源:StatusControllerSpec.php

示例13: test

 public function test()
 {
     $routerClass = $this->_routerClass;
     $routerInstance = new $routerClass();
     if (!isset($this->_expectModule)) {
         $this->_expectModule = $routerInstance->getDefaultModuleName();
     }
     if (!isset($this->_expectController)) {
         $this->_expectController = $routerInstance->getDefaultControllerName();
     }
     if (!isset($this->_expectAction)) {
         $this->_expectAction = $routerInstance->getDefaultActionName();
     }
     $postfix = "";
     if (isset($this->_requiredModule)) {
         $this->_router->requireModule($this->_requiredModule);
         if ($this->_requiredModule) {
             $postfix .= "(module '{$this->_requiredModule}' required)";
         } else {
             $postfix .= '(module required)';
         }
     }
     if (isset($this->_requiredController)) {
         $this->_router->requireController($this->_requiredController);
         if ($this->_requiredController) {
             $postfix .= "(controller '{$this->_requiredController}' required)";
         } else {
             $postfix .= '(controller required)';
         }
     }
     if (isset($this->_requiredAction)) {
         $this->_router->requireAction($this->_requiredAction);
         if ($this->_requiredAction) {
             $postfix .= "(action '{$this->_requiredAction}' required)";
         } else {
             $postfix .= '(action required)';
         }
     }
     $routable = $this->_router->route($this->_uri);
     if ($this->_isRoutable) {
         $this->_test->assertTrue($routable, "{$this->_routerClass} router should be able to route '{$this->_uri}' " . $postfix);
     } else {
         $this->_test->assertFalse($routable, "{$this->_routerClass} router should not be able to route '{$this->_uri}' " . $postfix);
         return;
     }
     $this->_test->assertEquals($this->_expectModule, $this->_router->getModuleName(), "{$this->_routerClass} routes {$this->_uri} to module '{$this->_expectModule}'");
     $this->_test->assertEquals($this->_expectController, $this->_router->getControllerName(), "{$this->_routerClass} routes {$this->_uri} to controller '{$this->_expectController}'");
     $this->_test->assertEquals($this->_expectAction, $this->_router->getActionName(), "{$this->_routerClass} routes {$this->_uri} to action '{$this->_expectAction}'");
     $this->_test->assertEquals($this->_expectArguments, $this->_router->getActionArguments(), "{$this->_routerClass} gets " . var_export($this->_expectArguments, true) . " from uri '{$this->_uri}'");
 }
开发者ID:WebSpider,项目名称:OpenConext-engineblock,代码行数:50,代码来源:AssertionBuilder.php

示例14: doStrictMethodCheck

 /**
  * @return void
  */
 protected function doStrictMethodCheck()
 {
     if ($this->isStatic()) {
         $errMsg = "#{$this->methodName} is an instance method on the class {$this->className}, but you expected it to be static.";
     } else {
         $errMsg = "#{$this->methodName} is a static method on the class {$this->className}, but you expected it to be an instance method.";
     }
     try {
         $reflectionMethod = new \ReflectionMethod($this->className, $this->methodName);
         $this->testCase->assertTrue($reflectionMethod->isStatic() == $this->isStatic(), $errMsg);
         $this->testCase->assertFalse($reflectionMethod->isPrivate(), "#{$this->methodName} is a private method on {$this->className}, but you cannot mock a private method.");
     } catch (\ReflectionException $e) {
         $necessaryMagicMethod = $this->isStatic() ? '__callStatic' : '__call';
         $this->testCase->assertTrue(method_exists($this->className, $necessaryMagicMethod), "The method #{$this->methodName} does not exist on the class {$this->className}");
     }
 }
开发者ID:box,项目名称:shmock,代码行数:19,代码来源:StaticSpec.php

示例15: errorHandler

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @category   tests   
 * @package    log4php
 * @subpackage appenders
 * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @version    SVN: $Id$
 * @link       http://logging.apache.org/log4php
 */
function errorHandler($errno, $errstr, $errfile, $errline)
{
    switch ($errno) {
        case E_USER_ERROR:
            PHPUnit_Framework_TestCase::assertEquals($errstr, "ERROR - testmessage" . PHP_EOL);
            break;
        case E_USER_WARNING:
            PHPUnit_Framework_TestCase::assertEquals($errstr, "WARN - testmessage" . PHP_EOL);
            break;
        case E_USER_NOTICE:
            PHPUnit_Framework_TestCase::assertEquals($errstr, "DEBUG - testmessage" . PHP_EOL);
            break;
        default:
            PHPUnit_Framework_TestCase::assertTrue(false);
    }
}
开发者ID:dobreapa,项目名称:owasp-esapi-php,代码行数:39,代码来源:LoggerAppenderPhpTest.php


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