本文整理汇总了PHP中UnitTester::assertEquals方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester::assertEquals方法的具体用法?PHP UnitTester::assertEquals怎么用?PHP UnitTester::assertEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTester
的用法示例。
在下文中一共展示了UnitTester::assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetUnit
public function testSetUnit()
{
$metric = new Metric();
$this->tester->assertFalse($metric->setUnit('Invalid'), 'Metric::setUnit invalid unit set failed!');
$metric->setUnit('Kilobits/Second');
$this->tester->assertEquals('Kilobits/Second', $metric->getUnit(), 'Metric::setUnit failed!');
}
示例2: testSeverityComparer
/**
* @dataProvider casesSeverityComparer
*
* @param int $expected
* @param string $a
* @param string $b
*/
public function testSeverityComparer($expected, $a, $b)
{
$fw = new FileWrapper([]);
$class = new ReflectionClass(FileWrapper::class);
$severityComparer = $class->getMethod('severityComparer');
$severityComparer->setAccessible(true);
$this->tester->assertEquals($expected, $severityComparer->invoke($fw, $a, $b));
}
示例3: testGetYear
public function testGetYear()
{
/**
* @var $object MTSXML
*/
$object = simplexml_load_file(Yii::getAlias('@data') . '/mts_report.xml', MTSXML::className());
$this->tester->assertEquals($object->getYear(), '2014');
}
示例4: testFailureComparer
/**
* @param int $expected
* @param array $a
* @param array $b
*
* @dataProvider casesFailureComparer
*/
public function testFailureComparer($expected, array $a, array $b)
{
$rw = new ReportWrapper([]);
$class = new ReflectionClass(ReportWrapper::class);
$failureComparer = $class->getMethod('failureComparer');
$failureComparer->setAccessible(true);
$this->tester->assertEquals($expected, $failureComparer->invoke($rw, $a, $b));
}
示例5: testValidateAttribute
public function testValidateAttribute()
{
$this->tester->haveInCollection(Number::collectionName(), ['number' => '9101234567']);
$this->specify("Test validate", function ($number, $expected) {
$this->model['number'] = $number;
$this->model->validate(['number']);
$this->tester->assertEquals($expected, $this->model->hasErrors());
}, ['examples' => [['9101234567', false], ['1111111111', true], ['9121111111', true]]]);
}
示例6: testResetJob
/**
* Test resetiranja joba
* @depends testRunJob
* @param \UnitTester $I
*/
public function testResetJob(\UnitTester $I)
{
$job = $this->job;
$this->jm->resetJob($job);
$I->assertEquals(0, $job->getStatus());
$I->assertEquals(0, count($job->getReports()));
$I->assertEquals(0, strlen($job->getLog()));
$I->assertEmpty($job->getAlert());
}
示例7: tryToCreateNewChunk
public function tryToCreateNewChunk(UnitTester $I)
{
$data = ['id' => 1, 'name' => 'HEADER', 'description' => 'header stripe for main_site pages', 'snippet' => '<header>Header stripe</header>'];
$r = new \Modvert\Resource\Modx\Chunk($data);
$I->assertEquals(1, $r->getId());
$I->assertEquals(\Modvert\Resource\ResourceType::CHUNK, $r->getType());
$I->assertEquals('HEADER', $r->getName());
$I->assertEquals($data, $r->getCleanFields());
}
示例8: parseSubscriptionCancelled
public function parseSubscriptionCancelled(UnitTester $I)
{
$parser = new \BB\Services\Payment\GoCardlessWebhookParser();
$parser->parseResponse($this->subscriptionCancelledPayload());
$I->assertEquals('cancelled', $parser->getAction());
$I->assertEquals('subscription', $parser->getResourceType());
$I->assertEquals(1, count($parser->getSubscriptions()));
$I->assertEquals(0, count($parser->getBills()));
$this->assertSubscriptionFormat($I, $parser->getSubscriptions());
}
示例9: testRun
public function testRun()
{
$result = 'Hello world';
$route = new router\Container(['test/route/{name:\\d}' => function ($request) use($result) {
$this->tester->assertNotEmpty($request);
$this->tester->assertTrue($request instanceof router\Request);
return $result;
}]);
$out = $route->route('test/route/1');
$this->tester->assertEquals($out, $result);
}
示例10: paymentDateChange
public function paymentDateChange(UnitTester $I)
{
$user = \BB\Entities\User::create(['given_name' => 'Jon', 'family_name' => 'Doe', 'email' => 'month-test@example.com']);
$I->assertEquals(0, $user->payment_day);
$user->payment_day = 10;
$user->save();
$I->assertEquals(10, $user->payment_day);
$user->payment_day = 28;
$user->save();
$I->assertEquals(28, $user->payment_day);
$user->payment_day = 31;
$user->save();
$I->assertEquals(1, $user->payment_day);
}
示例11: testRun
/**
* @param int $exitCode
* @param array $options
* @param bool $withJar
* @param string $expectedStdOutput
*
* @dataProvider casesRun
*/
public function testRun($exitCode, $options, $withJar, $expectedStdOutput)
{
$container = \Robo\Robo::createDefaultContainer();
\Robo\Robo::setContainer($container);
$mainStdOutput = new \Helper\Dummy\Output();
$options += ['workingDirectory' => '.', 'assetJarMapping' => ['report' => ['phpcsLintRun', 'report']], 'reports' => ['json' => null]];
/** @var \Cheppers\Robo\Phpcs\Task\PhpcsLintFiles $task */
$task = Stub::construct(PhpcsLintFiles::class, [$options, []], ['processClass' => \Helper\Dummy\Process::class, 'phpCodeSnifferCliClass' => \Helper\Dummy\PHP_CodeSniffer_CLI::class]);
$processIndex = count(\Helper\Dummy\Process::$instances);
\Helper\Dummy\Process::$prophecy[$processIndex] = ['exitCode' => $exitCode, 'stdOutput' => $expectedStdOutput];
\Helper\Dummy\PHP_CodeSniffer_CLI::$numOfErrors = $exitCode ? 42 : 0;
\Helper\Dummy\PHP_CodeSniffer_CLI::$stdOutput = $expectedStdOutput;
$task->setLogger($container->get('logger'));
$task->setOutput($mainStdOutput);
$assetJar = null;
if ($withJar) {
$assetJar = new AssetJar();
$task->setAssetJar($assetJar);
}
$result = $task->run();
$this->tester->assertEquals($exitCode, $result->getExitCode(), 'Exit code is different than the expected.');
$this->tester->assertEquals($options['workingDirectory'], \Helper\Dummy\Process::$instances[$processIndex]->getWorkingDirectory());
if ($withJar) {
/** @var \Cheppers\LintReport\ReportWrapperInterface $reportWrapper */
$reportWrapper = $assetJar->getValue(['phpcsLintRun', 'report']);
$this->tester->assertEquals(json_decode($expectedStdOutput, true), $reportWrapper->getReport(), 'Output equals');
} else {
$this->tester->assertContains($expectedStdOutput, $mainStdOutput->output, 'Output contains');
}
}
示例12: testRun
/**
* This way cannot be tested those cases when the lint process failed.
*
* @param int $exitCode
* @param array $options
* @param bool $withJar
* @param bool $expectedStdOutput
*
* @dataProvider casesRun
*/
public function testRun($exitCode, $options, $withJar, $expectedStdOutput)
{
$container = \Robo\Robo::createDefaultContainer();
\Robo\Robo::setContainer($container);
$mainStdOutput = new \Helper\Dummy\Output();
$options += ['workingDirectory' => 'my-working-dir', 'assetJarMapping' => ['report' => ['scssLintRun', 'report']], 'format' => 'JSON', 'failOn' => 'warning', 'failOnNoFiles' => false];
/** @var \Cheppers\Robo\ScssLint\Task\Run $task */
$task = Stub::construct(Task::class, [$options, []], ['processClass' => \Helper\Dummy\Process::class]);
$processIndex = count(\Helper\Dummy\Process::$instances);
\Helper\Dummy\Process::$prophecy[$processIndex] = ['exitCode' => $exitCode, 'stdOutput' => $expectedStdOutput];
$task->setLogger($container->get('logger'));
$task->setOutput($mainStdOutput);
$assetJar = null;
if ($withJar) {
$assetJar = new \Cheppers\AssetJar\AssetJar();
$task->setAssetJar($assetJar);
}
$result = $task->run();
$this->tester->assertEquals($exitCode, $result->getExitCode(), 'Exit code');
$this->tester->assertEquals($options['workingDirectory'], \Helper\Dummy\Process::$instances[$processIndex]->getWorkingDirectory(), 'Working directory');
if ($withJar) {
/** @var \Cheppers\Robo\ScssLint\LintReportWrapper\ReportWrapper $reportWrapper */
$reportWrapper = $assetJar->getValue(['scssLintRun', 'report']);
$this->tester->assertEquals(json_decode($expectedStdOutput, true), $reportWrapper->getReport(), 'Output equals with jar');
} else {
$this->tester->assertContains($expectedStdOutput, $mainStdOutput->output, 'Output contains');
}
}
示例13: testSetLanguageUrl
public function testSetLanguageUrl()
{
$app = \Yii::$app;
/** @var \bl\locale\UrlManager $urlManager */
$urlManager = clone $app->urlManager;
\Codeception\Util\Debug::debug("Before parse request app language: {$app->language}");
$urlManager->detectInCookie = false;
$urlManager->detectInSession = false;
$language = 'uk-UA';
$url = "{$language}/site/index";
$request = $app->request;
$request->setPathInfo($url);
$parse = $urlManager->parseRequest($request);
\Codeception\Util\Debug::debug("After parse request app language: {$app->language}");
$this->tester->assertEquals($language, \Yii::$app->language);
}
示例14: testHideDefaoultLanguage
public function testHideDefaoultLanguage()
{
$mockApp = $this->app;
/** @var \bl\locale\UrlManager $urlManager */
$urlManager = clone $mockApp->urlManager;
$urlManager->showDefault = false;
$url = 'site/index';
\Codeception\Util\Debug::debug("Default language: {$mockApp->sourceLanguage}");
$actual = $urlManager->createUrl([$url, $urlManager->languageKey => 'en-US']);
$expected = implode('/', ['', $url]);
\Codeception\Util\Debug::debug("Hiden default language: {$actual}");
$this->tester->assertEquals($expected, $actual);
$language = 'ru-RU';
$actual = $urlManager->createUrl([$url, $urlManager->languageKey => $language]);
$expected = implode('/', ['', $language, $url]);
\Codeception\Util\Debug::debug("Change language: {$actual}");
$this->tester->assertEquals($actual, $expected);
}
示例15: testRun
/**
* @param array $expected
* @param array $options
* @param array $properties
*
* @dataProvider casesRun
*/
public function testRun(array $expected, array $options, array $files, array $properties = [])
{
$container = \Robo\Robo::createDefaultContainer();
\Robo\Robo::setContainer($container);
$mainStdOutput = new \Helper\Dummy\Output();
$properties += ['processClass' => \Helper\Dummy\Process::class];
/** @var \Cheppers\Robo\Phpcs\Task\PhpcsLintInput $task */
$task = Stub::construct(PhpcsLintInput::class, [$options, []], $properties);
$processIndex = count(\Helper\Dummy\Process::$instances);
foreach ($files as $file) {
\Helper\Dummy\Process::$prophecy[$processIndex] = ['exitCode' => $file['lintExitCode'], 'stdOutput' => $file['lintStdOutput']];
$processIndex++;
}
$task->setLogger($container->get('logger'));
$task->setOutput($mainStdOutput);
$result = $task->run();
$this->tester->assertEquals($expected['exitCode'], $result->getExitCode());
/** @var \Cheppers\LintReport\ReportWrapperInterface $reportWrapper */
$reportWrapper = $result['report'];
$this->tester->assertEquals($expected['report'], $reportWrapper->getReport());
}