• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

	/**
	 * Creates and instance of the mock JApplication object.
	 *
	 * @param   TestCase  $test  A test object.
	 * @param   array     $data  Data to prime the cache with.
	 *
	 * @return  object
	 *
	 * @since   12.1
	 */
	public static function create(TestCase $test, $data = array())
	{
		self::$cache = $data;

		// Collect all the relevant methods in JConfig.
		$methods = array(
			'get',
			'store',
		);

		// Create the mock.
		$mockObject = $test->getMock(
			'JCache',
			$methods,
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			false
		);

		$test->assignMockCallbacks(
			$mockObject,
			array(
				'get' => array(get_called_class(), 'mockGet'),
				'store' => array(get_called_class(), 'mockStore'),
			)
		);

		return $mockObject;
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:42,代码来源:cache.php


示例2: testAll

 public function testAll()
 {
     $obj = new \PHPCraftdream\TestCase\TestCaseClassForTest();
     $testCase = new TestCase();
     $rand1 = bin2hex(random_bytes(5));
     $rand2 = bin2hex(random_bytes(5));
     $obj->setProtected($rand1);
     $this->assertEquals($rand1, $obj->getProtected());
     $obj->setPrivate($rand2);
     $this->assertEquals($rand2, $obj->getPrivate());
     //-------------------------------------------------------
     $rand3 = bin2hex(random_bytes(5));
     $rand4 = bin2hex(random_bytes(5));
     $testCase->setProp($obj, 'propertyProtected', $rand3);
     $this->assertEquals($rand3, $obj->getProtected());
     $testCase->setProp($obj, 'propertyPrvate', $rand4);
     $this->assertEquals($rand4, $obj->getPrivate());
     //-------------------------------------------------------
     $rand5 = bin2hex(random_bytes(5));
     $rand6 = bin2hex(random_bytes(5));
     $obj->setProtected($rand5);
     $this->assertEquals($rand5, $testCase->getProp($obj, 'propertyProtected'));
     $obj->setPrivate($rand6);
     $this->assertEquals($rand6, $testCase->getProp($obj, 'propertyPrvate'));
     //-------------------------------------------------------
 }
开发者ID:phpcraftdream,项目名称:testcase,代码行数:26,代码来源:TestCaseTest.php


示例3: create

 /**
  * Creates and instance of the mock WebServiceApplicationWeb object.
  *
  * The test can implement the following overrides:
  * - mockAppendBody
  * - mockGetBody
  * - mockPrepentBody
  * - mockSetBody
  *
  * If any *Body methods are implemented in the test class, all should be implemented otherwise behaviour will be unreliable.
  *
  * @param   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   11.3
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     // Collect all the relevant methods in WebServiceApplicationWeb (work in progress).
     $methods = array('allowCache', 'appendBody', 'clearHeaders', 'close', 'execute', 'get', 'getBody', 'getDocument', 'getHeaders', 'getIdentity', 'getLanguage', 'getSession', 'loadConfiguration', 'loadDispatcher', 'loadDocument', 'loadIdentity', 'loadLanguage', 'loadSession', 'prependBody', 'redirect', 'registerEvent', 'sendHeaders', 'set', 'setBody', 'setHeader', 'triggerEvent');
     // Create the mock.
     $mockObject = $test->getMock('WebServiceApplicationWeb', $methods, array(), '', true);
     // Mock calls to JApplicationWeb::getDocument().
     $mockObject->expects($test->any())->method('getDocument')->will($test->returnValue(TestMockDocument::create($test)));
     // Mock calls to JApplicationWeb::getLanguage().
     $mockObject->expects($test->any())->method('getLanguage')->will($test->returnValue(TestMockLanguage::create($test)));
     // Mock a call to JApplicationWeb::getSession().
     if (isset($options['session'])) {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue($options['session']));
     } else {
         $mockObject->expects($test->any())->method('getSession')->will($test->returnValue(TestMockSession::create($test)));
     }
     $test->assignMockCallbacks($mockObject, array('appendBody' => array(is_callable(array($test, 'mockAppendBody')) ? $test : get_called_class(), 'mockAppendBody'), 'getBody' => array(is_callable(array($test, 'mockGetBody')) ? $test : get_called_class(), 'mockGetBody'), 'prependBody' => array(is_callable(array($test, 'mockPrependBody')) ? $test : get_called_class(), 'mockPrependBody'), 'setBody' => array(is_callable(array($test, 'mockSetBody')) ? $test : get_called_class(), 'mockSetBody')));
     // Reset the body storage.
     self::$body = array();
     return $mockObject;
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:43,代码来源:web.php


示例4: create

	/**
	 * Creates and instance of the mock JApplicationCli object.
	 *
	 * @param   TestCase  $test     A test object.
	 * @param   array     $options  A set of options to configure the mock.
	 *
	 * @return  PHPUnit_Framework_MockObject_MockObject
	 *
	 * @since   12.2
	 */
	public static function create($test, $options = array())
	{
		// Collect all the relevant methods in JApplicationCli.
		$methods = array(
			'get',
			'execute',
			'loadConfiguration',
			'out',
			'in',
			'set',
		);

		// Create the mock.
		$mockObject = $test->getMock(
			'JApplicationCli',
			$methods,
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			true
		);

		return $mockObject;
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:36,代码来源:cli.php


示例5: testGetReflectionProperty

 /**
  * Tests PhpUnitTest\TestCase::getReflectionProperty
  */
 public function testGetReflectionProperty()
 {
     $sut = new TestCase();
     $testSubject = new TestingClass();
     $result = $sut->getReflectionProperty($testSubject, 'property');
     $this->assertInstanceOf('\\ReflectionProperty', $result);
 }
开发者ID:corycollier,项目名称:php-unit-test,代码行数:10,代码来源:TestCaseTest.php


示例6: create

 /**
  * Creates and instance of the mock JApplicationCli object.
  *
  * @param   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   12.2
  */
 public static function create($test, $options = array())
 {
     // Collect all the relevant methods in JApplicationCli.
     $methods = array('get', 'execute', 'loadConfiguration', 'out', 'in', 'set');
     // Create the mock.
     $mockObject = $test->getMock('JApplicationCli', $methods, array(), '', true);
     return $mockObject;
 }
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:18,代码来源:cli.php


示例7: matched

 /**
  * Check if the test object should be filtered out.
  *
  * @param TestSuite|TestCase $test
  * @return bool
  */
 protected function matched($test)
 {
     foreach ($this->groups as $group) {
         if ($test->in_group($group)) {
             return false;
         }
     }
     return true;
 }
开发者ID:v2e4lisp,项目名称:preview,代码行数:15,代码来源:GroupExcluded.php


示例8: create

 /**
  * Creates and instance of the mock JApplicationCli object.
  *
  * @param   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   12.2
  */
 public static function create($test, $options = array())
 {
     // Collect all the relevant methods in JApplicationCli.
     $methods = self::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('JApplicationCli', $methods, array(), '', true);
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:19,代码来源:cli.php


示例9: create

 /**
  * Creates and instance of the mock JApplication object.
  *
  * @param   TestCase  $test  A test object.
  * @param   array     $data  Data to prime the cache with.
  *
  * @return  object
  *
  * @since   12.1
  */
 public static function create(TestCase $test, $data = array())
 {
     self::$cache = $data;
     // Collect all the relevant methods in JConfig.
     $methods = array('get', 'store');
     // Create the mock.
     $mockObject = $test->getMock('JCache', $methods, array(), '', false);
     $test->assignMockCallbacks($mockObject, array('get' => array(get_called_class(), 'mockGet'), 'store' => array(get_called_class(), 'mockStore')));
     return $mockObject;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:20,代码来源:cache.php


示例10: outcomeOf

 /**
  * Returns the outcome of a specific test
  *
  * @param   unittest.TestCase test
  * @return  unittest.TestOutcome
  */
 public function outcomeOf(TestCase $test)
 {
     $key = $test->hashCode();
     foreach ([$this->succeeded, $this->failed, $this->skipped] as $lookup) {
         if (isset($lookup[$key])) {
             return $lookup[$key];
         }
     }
     return null;
 }
开发者ID:xp-framework,项目名称:unittest,代码行数:16,代码来源:TestResult.class.php


示例11: create

 /**
  * Creates and instance of the mock JApplicationCms object.
  *
  * The test can implement the following overrides:
  * - mockAppendBody
  * - mockGetBody
  * - mockPrepentBody
  * - mockSetBody
  *
  * If any *Body methods are implemented in the test class, all should be implemented otherwise behaviour will be unreliable.
  *
  * @param   TestCase  $test     A test object.
  * @param   array     $options  A set of options to configure the mock.
  *
  * @return  PHPUnit_Framework_MockObject_MockObject
  *
  * @since   3.2
  */
 public static function create($test, $options = array())
 {
     // Set expected server variables.
     if (!isset($_SERVER['HTTP_HOST'])) {
         $_SERVER['HTTP_HOST'] = 'localhost';
     }
     $methods = self::getMethods();
     // Create the mock.
     $mockObject = $test->getMock('JApplicationCms', $methods, array(), '', true);
     $mockObject = self::addBehaviours($test, $mockObject, $options);
     return $mockObject;
 }
开发者ID:akirsoft,项目名称:joomla-cms,代码行数:30,代码来源:cms.php


示例12: addTestCase

 /**
  * Add testcases to the provided TestSuite from the XML node
  *
  * @param TestSuite         $testSuite
  * @param \SimpleXMLElement $xml
  */
 public function addTestCase(TestSuite $testSuite, \SimpleXMLElement $xml)
 {
     foreach ($xml->xpath('./testcase') as $element) {
         $testcase = new TestCase((string) $element['name'], (int) $element['assertions'], (double) $element['time'], (string) $element['class'], (string) $element['file'], (int) $element['line']);
         if ($element->error) {
             $testcase->setError(new TestError((string) $element->error[0]->attributes()->type, (string) $element->error[0]));
         }
         if ($element->failure) {
             $testcase->setFailure(new TestFailure((string) $element->failure[0]->attributes()->type, (string) $element->failure[0]));
         }
         $testSuite->addTestCase($testcase);
     }
 }
开发者ID:sonata-project,项目名称:composer-archive-creator,代码行数:19,代码来源:PHPUnitLoader.php


示例13: tearDown

 /**
  * Overrides the parent tearDown method.
  *
  * @return  void
  *
  * @see     PHPUnit_Framework_TestCase::tearDown()
  * @since   11.1
  */
 protected function tearDown()
 {
     $this->restoreFactoryState();
     // Reset the dispatcher instance.
     TestReflection::setValue('JPluginHelper', 'plugins', null);
     parent::tearDown();
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:15,代码来源:JModelFormTest.php


示例14: addRequiredMethod

 /**
  * @param string $methodName
  * @param bool $moreThanOnce
  */
 public function addRequiredMethod($methodName, $moreThanOnce = false)
 {
     if ($moreThanOnce) {
         $this->mock->expects($this->testCase->atLeastOnce())->method($methodName)->with();
     } else {
         $this->mock->expects($this->testCase->once())->method($methodName)->with();
     }
 }
开发者ID:brick,项目名称:brick,代码行数:12,代码来源:MockBuilder.php


示例15: setUp

 /**
  * Set up test env
  *
  * @return void
  * @author Dan Cox
  */
 public function setUp()
 {
     parent::setUp();
     $this->app->add(new ProjectCreate());
     $this->command = $this->app->find('project:create');
     $this->config = m::mock('config');
 }
开发者ID:danzabar,项目名称:alice,代码行数:13,代码来源:ProjectCreateTest.php


示例16: tearDown

 /**
  * Delete the keys that were added to the database during the test
  */
 public function tearDown()
 {
     parent::tearDown();
     Redis::del($this->testingResource->testModelHashId);
     Redis::del($this->testingResource->testModelSearchableId);
     Redis::del("testmodels");
 }
开发者ID:ryuske,项目名称:redismodel,代码行数:10,代码来源:CreateResourceTest.php


示例17: setUp

 /**
  * Called before each test.
  */
 public function setUp()
 {
     parent::setUp();
     $this->user = factory(\App\User::class)->create();
     $this->client = factory(\App\Client::class)->create(['user_id' => $this->user->id]);
     $this->bill = factory(\App\Bill::class)->create(['user_id' => $this->user->id, 'client_id' => $this->client->id, 'paid' => 1]);
 }
开发者ID:bitller,项目名称:nova,代码行数:10,代码来源:MarkBillAsUnpaidTest.php


示例18: setup

 public function setup()
 {
     parent::setup();
     Session::start();
     $this->app["request"]->setSession(Session::driver());
     FieldPresenter::presenter(null);
 }
开发者ID:smallhadroncollider,项目名称:laravel-form-presenter,代码行数:7,代码来源:FieldSetPresenterTest.php


示例19: setUp

 public function setUp()
 {
     parent::setUp();
     Artisan::call('migrate');
     Artisan::call('db:seed');
     Session::start();
 }
开发者ID:BaobabHealthTrust,项目名称:iBLIS,代码行数:7,代码来源:TestControllerTest.php


示例20: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->options = new JRegistry();
     $this->uri = new JUri();
     $this->object = new JGoogleEmbedAnalytics($this->options, $this->uri);
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:14,代码来源:JGoogleEmbedAnalyticsTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TestCaseDatabase类代码示例发布时间:2022-05-23
下一篇:
PHP TestBase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap