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


PHP PHPUnit_Framework_TestCase::assertContains方法代码示例

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


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

示例1: testFactory

 /**
  * Test a factory.
  *
  * @param  string $className
  * @return void
  */
 public function testFactory($classname, array $requiredOptions, array $options)
 {
     // Test that the factory does not allow a scalar option.
     try {
         $classname::factory(0);
         $this->testCase->fail('An expected exception was not thrown');
     } catch (\Zend\Mvc\Router\Exception\InvalidArgumentException $e) {
         $this->testCase->assertContains('factory expects an array or Traversable set of options', $e->getMessage());
     }
     // Test required options.
     foreach ($requiredOptions as $option => $exceptionMessage) {
         $testOptions = $options;
         unset($testOptions[$option]);
         try {
             $classname::factory($testOptions);
             $this->testCase->fail('An expected exception was not thrown');
         } catch (\Zend\Mvc\Router\Exception\InvalidArgumentException $e) {
             $this->testCase->assertContains($exceptionMessage, $e->getMessage());
         }
     }
     // Create the route, will throw an exception if something goes wrong.
     $classname::factory($options);
     // Try the same with an iterator.
     $classname::factory(new ArrayIterator($options));
 }
开发者ID:ninahuanca,项目名称:zf2,代码行数:31,代码来源:FactoryTester.php

示例2: testDump

 public function testDump()
 {
     ob_start();
     Debug::dump('some string');
     parent::assertContains('some', ob_get_clean());
     ob_start();
     Debug::dump(new \Exception('hello world'));
     parent::assertContains('Exception', ob_get_clean());
 }
开发者ID:coreorm,项目名称:utility,代码行数:9,代码来源:debugTest.php

示例3: testGetSkypeButton

 /**
  * @dataProvider optionsDataProvider
  * @param string $username
  * @param array $options
  * @param array $expectedOptions
  * @param string $expectedTemplate
  */
 public function testGetSkypeButton($username, $options, $expectedOptions, $expectedTemplate)
 {
     $env = $this->getMockBuilder('\\Twig_Environment')->disableOriginalConstructor()->getMock();
     $env->expects($this->once())->method('render')->with($expectedTemplate, $this->anything())->will($this->returnCallback(function ($template, $options) use($expectedOptions, $username) {
         \PHPUnit_Framework_TestCase::assertArrayHasKey('name', $options['options']);
         \PHPUnit_Framework_TestCase::assertEquals($expectedOptions['name'], $options['options']['name']);
         \PHPUnit_Framework_TestCase::assertArrayHasKey('participants', $options['options']);
         \PHPUnit_Framework_TestCase::assertEquals($expectedOptions['participants'], $options['options']['participants']);
         \PHPUnit_Framework_TestCase::assertArrayHasKey('element', $options['options']);
         \PHPUnit_Framework_TestCase::assertContains('skype_button_' . md5($username), $options['options']['element']);
         return 'BUTTON_CODE';
     }));
     $this->assertEquals('BUTTON_CODE', $this->extension->getSkypeButton($env, $username, $options));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:21,代码来源:SkypeButtonExtensionTest.php

示例4: it_dispatches_a_static_template_request

 public function it_dispatches_a_static_template_request()
 {
     // init
     $this->setConfig();
     $request = new Request($this->object->getWrappedObject()->config);
     $response = new Response($this->object->getWrappedObject()->config);
     // static request
     $request->setPath('/test/static');
     $this->dispatchRequest($request, $response);
     $actual = $response->getBody();
     $expectedBody = '<h1>Hello Static</h1>';
     Assertions::assertContains($expectedBody, $actual, 'should inject body template');
     $expectedMarkup = '<html';
     Assertions::assertContains($expectedMarkup, $actual, 'should generate page container');
 }
开发者ID:bnowack,项目名称:backbone-php,代码行数:15,代码来源:RouterSpec.php

示例5: it_adds_the_app_title_to_the_page_title

 public function it_adds_the_app_title_to_the_page_title()
 {
     // init
     $config = new Config();
     $this->config = $config;
     $request = new Request();
     $response = new Response();
     // request with appended app title
     $config->set('appTitle', 'app');
     $config->set('pageTitleDelimiter', ' :: ');
     $request->setPath('/test');
     $route = (object) ["path" => "/test", "type" => "template", "template" => "/test/fixtures/static-body.html.tpl", "model" => (object) ["pageTemplate" => "/test/fixtures/index.html.tpl", "pageTitle" => 'page']];
     $this->handleTemplateRouteRequest($request, $response, $route);
     Assertions::assertContains('<title>page :: app</title>', $response->getBody(), 'should have page title and app title');
     // request with empty page title
     $route->model->pageTitle = null;
     $this->handleTemplateRouteRequest($request, $response, $route);
     Assertions::assertContains('<title>app</title>', $response->getBody(), 'should have app title only');
     // request with empty app title
     $route->model->pageTitle = 'page';
     $config->set('appTitle', null);
     $this->handleTemplateRouteRequest($request, $response, $route);
     Assertions::assertContains('<title>page</title>', $response->getBody(), 'should have page title only');
 }
开发者ID:bnowack,项目名称:backbone-php,代码行数:24,代码来源:ControllerSpec.php

示例6: assertContains

 /**
  * @param mixed|CM_Comparable $needle
  * @param Traversable|string  $haystack
  * @param string              $message
  * @param boolean             $ignoreCase
  * @param boolean             $checkForObjectIdentity
  * @param bool                $checkForNonObjectIdentity
  * @throws CM_Exception_Invalid
  */
 public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 {
     if ($needle instanceof CM_Comparable) {
         if (!(is_array($haystack) || $haystack instanceof Traversable)) {
             throw new CM_Exception_Invalid('Haystack is not traversable.');
         }
         $match = false;
         foreach ($haystack as $hay) {
             if ($needle->equals($hay)) {
                 $match = true;
                 break;
             }
         }
         self::assertTrue($match, 'Needle not contained.');
     } else {
         parent::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity, $checkForNonObjectIdentity);
     }
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:27,代码来源:TestCase.php

示例7: testInvokesDefaultErrorFormatterWhenDebugIsEnabledAndThrowableCaught

 /**
  * @dataProvider throwables
  */
 public function testInvokesDefaultErrorFormatterWhenDebugIsEnabledAndThrowableCaught($throwable)
 {
     $next = function () use($throwable) {
         throw $throwable;
     };
     $this->renderer->render(ErrorHandler::TEMPLATE_ERROR, Argument::that(function ($argument) use($throwable) {
         TestCase::assertInternalType('array', $argument);
         TestCase::assertArrayHasKey('error', $argument);
         $error = $argument['error'];
         TestCase::assertContains($throwable->getMessage(), $error);
         TestCase::assertContains((string) $throwable->getCode(), $error);
         TestCase::assertContains($throwable->getTraceAsString(), $error);
         return true;
     }))->willReturn('error content');
     $handler = new ErrorHandler($this->renderer->reveal(), true);
     $result = $handler($this->createRequestMock()->reveal(), $this->createResponseMock()->reveal(), $next);
     $this->assertInstanceOf(HtmlResponse::class, $result);
     $this->assertEquals(500, $result->getStatusCode());
     $this->assertEquals('error content', (string) $result->getBody());
 }
开发者ID:vrkansagara,项目名称:mwop.net,代码行数:23,代码来源:ErrorHandlerTest.php

示例8: assertContains

 public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE, $checkForNonObjectIdentity = false)
 {
     if ($haystack instanceof DBField) {
         $haystack = (string) $haystack;
     }
     parent::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity, $checkForNonObjectIdentity);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:7,代码来源:SapphireTest.php

示例9: dataPicasaPhotoCallback

/**
 * Dummy method
 *
 * @param   string   $url      Path to the resource.
 * @param   mixed    $data     Either an associative array or a string to be sent with the request.
 * @param   array    $headers  An array of name-value pairs to include in the header of the request.
 * @param   integer  $timeout  Read timeout in seconds.
 *
 * @return  JHttpResponse
 *
 * @since   12.3
 */
function dataPicasaPhotoCallback($url, $data, array $headers = null, $timeout = null)
{
	PHPUnit_Framework_TestCase::assertContains('<title>New Title</title>', $data);

	$response = new stdClass;

	$response->code = 200;
	$response->headers = array('Content-Type' => 'application/atom+xml');
	$response->body = $data;

	return $response;
}
开发者ID:realityking,项目名称:joomla-platform,代码行数:24,代码来源:JGoogleDataPicasaPhotoTest.php

示例10: testAdd

 public function testAdd($data)
 {
     $count = count($this->entityGet());
     $containsBeforeAdd = $this->countDataInCollection($data);
     $returnOfAddMethod = $this->entityAdd($data);
     if ($this->fluent) {
         TestCase::assertEquals($this->entity, $returnOfAddMethod, $this->msg(self::$MSG_ADD_METHOD_NOT_FLUENT));
     }
     TestCase::assertContains($data, $this->entityGet(), $this->msg(self::$MSG_ADD_METHOD_DOES_NOT_ADD));
     if ($this->unique && $containsBeforeAdd > 0) {
         TestCase::assertCount($count, $this->entityGet(), $this->msg(self::$MSG_ADD_METHOD_NOT_UNIQUE));
     } else {
         TestCase::assertCount($count + 1, $this->entityGet(), $this->msg(self::$MSG_ADD_METHOD_UNIQUE));
     }
     return $this;
 }
开发者ID:jngermon,项目名称:phpunit-entity-tester,代码行数:16,代码来源:AccessorCollectionTester.php

示例11: assertGeneratedContent

 protected function assertGeneratedContent($expected, $actual)
 {
     $this->markTestIncomplete('Find a way to compare this!');
     return parent::assertContains(preg_replace('/[\\t\\r\\n]/', '', $expected), preg_replace('/[\\t\\r\\n]/', '', $actual));
 }
开发者ID:bilalghouri,项目名称:KnpInvoice,代码行数:5,代码来源:TwigTest.php

示例12: iShouldSeeInTheElement

 /**
  * @Then I should see :value in the :tag element
  */
 public function iShouldSeeInTheElement($value, $tag)
 {
     $page = $this->getSession()->getPage();
     $el = $page->find('css', $tag);
     Assertions::assertNotNull($el);
     $actual = $el->getText();
     Assertions::assertContains($value, $actual);
 }
开发者ID:bnowack,项目名称:backbone-php,代码行数:11,代码来源:ProjectContext.php


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