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


PHP PHPUnit_Framework_TestCase::fail方法代码示例

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


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

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  * @param array[] $expectedCalls
  */
 function assertCalls(\PHPUnit_Framework_TestCase $testCase, array $expectedCalls)
 {
     if (array_values($expectedCalls) !== $expectedCalls) {
         throw new \InvalidArgumentException('$expectedCalls must be a numeric array with no keys missing.');
     }
     $extractFunction = array($this, 'callGetFunction');
     $testCase->assertEquals("\n" . implode("\n", array_map($extractFunction, $expectedCalls)) . "\n", "\n" . implode("\n", array_map($extractFunction, $this->calls)) . "\n");
     $testCase->assertEquals($expectedCalls, $this->calls);
     for ($i = 0; TRUE; ++$i) {
         $actualCall = isset($this->calls[$i]) ? $this->calls[$i] : NULL;
         $expectedCall = isset($expectedCalls[$i]) ? $expectedCalls[$i] : NULL;
         if (NULL === $actualCall && NULL === $expectedCall) {
             break;
         }
         if (NULL === $actualCall) {
             $testCase->fail("Call {$i} missing.\nExpected: " . var_export($expectedCall, TRUE));
             break;
         }
         if (NULL === $expectedCall) {
             $testCase->fail("Call {$i} was not expected.\nActual: " . var_export($actualCall, TRUE));
             break;
         }
         if ($actualCall !== $expectedCall) {
             $testCase->fail("Call {$i} mismatch.\nExpected: " . var_export($expectedCall, TRUE) . "\nActual: " . var_export($this->calls[$i], TRUE));
             break;
         }
     }
     $testCase->assertEquals($expectedCalls, $this->calls);
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:33,代码来源:CallLog.php

示例3: endTest

 /**
  * Checks if deployment configuration has been changed by a test
  *
  * Changing deployment configuration violates isolation between tests, so further tests may become broken.
  * To fix this issue, find out why this test changes deployment configuration.
  * If this is intentional, then it must be reverted to the previous state within the test.
  * After that, the application needs to be wiped out and reinstalled.
  *
  * @param \PHPUnit_Framework_TestCase $test
  * @return void
  */
 public function endTest(\PHPUnit_Framework_TestCase $test)
 {
     $config = $this->reader->load();
     if ($this->config != $config) {
         $error = "\n\nERROR: deployment configuration is corrupted. The application state is no longer valid.\n" . 'Further tests may fail.' . " This test failure may be misleading, if you are re-running it on a corrupted application.\n" . $test->toString() . "\n";
         $test->fail($error);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:DeploymentConfig.php

示例4: 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:phpleo,项目名称:viper,代码行数:14,代码来源:sfPHPUnitTest.class.php

示例5: processAssert

 /**
  * Assert that conformation message is present.
  *
  * @param Customer $customer
  * @param CustomerAccountEdit $customerAccountEdit
  * @return void
  */
 public function processAssert(Customer $customer, CustomerAccountEdit $customerAccountEdit)
 {
     $validationMessages = $customerAccountEdit->getAccountInfoForm()->getValidationMessages($customer);
     if (isset($validationMessages['password_confirmation'])) {
         \PHPUnit_Framework_Assert::assertEquals(self::CONFIRMATION_MESSAGE, $validationMessages['password_confirmation'], 'Wrong password confirmation validation text message.');
     } else {
         \PHPUnit_Framework_TestCase::fail('Password confirmation validation message is absent.');
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:AssertWrongPassConfirmationMessage.php

示例6: assertNotInLogs

 /**
  * Asserts that the log buffer does NOT contain specified message
  *
  * @param string $expected Message subsctring
  * @param string $errmsg The error message to display.
  *
  * @return void
  */
 public function assertNotInLogs($message, $errorMsg = "Unexpected string '%s' found in logs:\n\n%s")
 {
     foreach ($this->getLines() as $log) {
         if (false !== stripos($log, $message)) {
             $this->testCase->fail(sprintf($errorMsg, $message, var_export($this->getLines(), true)));
         }
     }
     $this->testCase->assertEquals(1, 1);
     // increase number of positive assertions
 }
开发者ID:farazdagi,项目名称:phrozn,代码行数:18,代码来源:TestOutputter.php

示例7: isSpecification

 public static function isSpecification(\PHPUnit_Framework_TestCase $test)
 {
     if ($test->getName(false) === NULL) {
         throw new \PHPUnit_Framework_Exception('PHPUnit_Framework_TestCase::$name must not be NULL.');
     }
     try {
         $class = new \ReflectionClass($test);
         $method = $class->getMethod($test->getName(false));
         $methodName = $method->getName();
         return substr($methodName, -4) == 'Spec' || preg_match('/\\s+@spec\\s+/', $method->getDocComment());
     } catch (\ReflectionException $e) {
         $test->fail($e->getMessage());
     }
     return false;
 }
开发者ID:aleczhang,项目名称:phpspock,代码行数:15,代码来源:PhpUnitAdapter.php

示例8: fail

 public static function fail($message = '')
 {
     // save in a static var that this particular test has failed
     // (but only if not called from subclass objects / multitests)
     if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests') {
         $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         for ($i = 0; $i < count($trace); $i++) {
             if (strpos($trace[$i]['function'], 'test') === 0) {
                 self::$failed_tests[$trace[$i]['function']] = true;
                 break;
             }
         }
     }
     parent::fail($message);
 }
开发者ID:TsobuEnterprise,项目名称:phpxmlrpc,代码行数:15,代码来源:3LocalhostTest.php

示例9: processResults

 /**
  * Analyze results of aggregated tests execution and complete test case appropriately
  *
  * @param array $results
  * @param int $passed
  * @return void
  */
 protected function processResults(array $results, $passed)
 {
     $totalCountsMessage = sprintf('Passed: %d, Failed: %d, Incomplete: %d, Skipped: %d.', $passed, count($results['PHPUnit_Framework_AssertionFailedError']), count($results['PHPUnit_Framework_IncompleteTestError']), count($results['PHPUnit_Framework_SkippedTestError']));
     if ($results['PHPUnit_Framework_AssertionFailedError']) {
         $this->_testCase->fail($totalCountsMessage . PHP_EOL . implode(PHP_EOL, $results['PHPUnit_Framework_AssertionFailedError']));
     }
     if (!$results['PHPUnit_Framework_IncompleteTestError'] && !$results['PHPUnit_Framework_SkippedTestError']) {
         return;
     }
     $message = $totalCountsMessage . PHP_EOL . implode(PHP_EOL, $results['PHPUnit_Framework_IncompleteTestError']) . PHP_EOL . implode(PHP_EOL, $results['PHPUnit_Framework_SkippedTestError']);
     if ($results['PHPUnit_Framework_IncompleteTestError']) {
         $this->_testCase->markTestIncomplete($message);
     } elseif ($results['PHPUnit_Framework_SkippedTestError']) {
         $this->_testCase->markTestSkipped($message);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:AggregateInvoker.php

示例10: testProvider

 /**
  * testFiles
  *
  * Run simple syntax checks, if the filename ends with pass.php - expect it to pass
  */
 public static function testProvider()
 {
     $tests = array();
     $standard = dirname(dirname(__FILE__));
     if (basename($standard) !== 'CakePHP') {
         PHPUnit_Framework_TestCase::fail("The dirname for the standard must be CakePHP");
     }
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/files'));
     foreach ($iterator as $dir) {
         if ($dir->isDir()) {
             continue;
         }
         $file = $dir->getPathname();
         $expectPass = substr($file, -8) === 'pass.php';
         $tests[] = array($file, $standard, $expectPass);
     }
     return $tests;
 }
开发者ID:frankfoerster,项目名称:cakephp2-codesniffer,代码行数:23,代码来源:CakePHPStandardTest.php

示例11: fail

 /**
  * Overwritten lime_test method
  *
  * @see lime_test#fail()
  */
 public function fail($message = '')
 {
     $this->testCase->fail($message);
     return false;
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:10,代码来源:sfPHPUnitTest.class.php

示例12: fail

 /**
  * Fails the test with specified error message
  *
  * @param string $message
  * @param \PHPUnit_Framework_TestCase $test
  * @throws \Exception
  */
 private static function fail($message, \PHPUnit_Framework_TestCase $test)
 {
     $test->fail("{$message} in the test '{$test->toString()}'");
     throw new \Exception('The above line was supposed to throw an exception.');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Cache.php

示例13: existeUnObjetoDe

 public function existeUnObjetoDe($name, $arg1, $arg2)
 {
     foreach ($this->getObjects($name) as $objeto) {
         if ($objeto[$arg1] == $arg2) {
             return true;
         }
     }
     \PHPUnit_Framework_TestCase::fail("No existe {$arg1} == {$arg2}");
     return false;
 }
开发者ID:bixlabs,项目名称:concepto-sises,代码行数:10,代码来源:RestContext.php

示例14: prepare

 protected function prepare()
 {
     $this->container = \Mockery::mock(Container::class)->makePartial();
     $schemaMapper = \Mockery::mock(SchemaMapper::class)->makePartial();
     $schemaMapper->shouldReceive('buildCredentialsFromInlineFormat')->once()->passthru();
     $this->container->shouldReceive('resolve')->once()->with('Domain\\Mapper\\Schema')->andReturn($schemaMapper);
     $credentialsMatcher = \Mockery::on(function ($args) {
         /** @var CredentialsInterface $credentials */
         $credentials = $args[0];
         \PHPUnit_Framework_TestCase::assertInstanceOf(CredentialsInterface::class, $credentials);
         $actual = $credentials->toArray();
         $expected = ["username" => "user1", "password" => "pass2", "host" => "sample.host", "database" => "sample_database"];
         if ($expected != $actual) {
             \PHPUnit_Framework_TestCase::fail('Check credentials format or sample.');
         }
         return true;
     });
     $pdo = \Mockery::mock(\PDO::class);
     $this->container->shouldReceive('resolve')->once()->with('Persistence\\Storage\\PDO', $credentialsMatcher)->andReturn($pdo);
     $storageMatcher = \Mockery::on(function ($args) use($pdo) {
         /** @var StorageInterface $storage */
         $storage = $args[0];
         if ($pdo != $storage) {
             \PHPUnit_Framework_TestCase::fail('Check pipes.');
         }
         return true;
     });
     $gateway = \Mockery::mock(MySQLGateway::class);
     $this->container->shouldReceive('resolve')->once()->with('Persistence\\Gateway\\Schema\\MySQL', $storageMatcher)->andReturn($gateway);
     $gatewayAndMapperMatcher = \Mockery::on(function ($args) use($gateway, $schemaMapper) {
         if ($args[0] != $gateway) {
             \PHPUnit_Framework_TestCase::fail('Gateway mismatch.');
         }
         if ($args[1] != $schemaMapper) {
             \PHPUnit_Framework_TestCase::fail('Mapper mismatch.');
         }
         return true;
     });
     $this->schemaService = \Mockery::mock(SchemaService::class);
     $this->container->shouldReceive('resolve')->once()->with('Infrastructure\\Services\\Schema', $gatewayAndMapperMatcher)->andReturn($this->schemaService);
     $classCommand = '\\DatabaseInspect\\Console\\Command\\DetailsCommand[execute]';
     $this->command = \Mockery::mock($classCommand, [$this->container])->makePartial();
     $this->input = \Mockery::mock(ArgvInput::class);
     $this->input->shouldReceive('getArgument')->once()->andReturn('user1:pass2@sample.host/sample_database');
     $this->output = \Mockery::mock(ConsoleOutput::class);
 }
开发者ID:bogdananton,项目名称:mysql-structure-inspect,代码行数:46,代码来源:ExecuteTest.php


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