本文整理汇总了PHP中UnitTester::assertTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester::assertTrue方法的具体用法?PHP UnitTester::assertTrue怎么用?PHP UnitTester::assertTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTester
的用法示例。
在下文中一共展示了UnitTester::assertTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasMethod
public function testHasMethod()
{
$arrayer = new \Mascame\Arrayer\Arrayer([]);
$arrayer->set('fruit', 'coconut');
$this->tester->assertTrue($arrayer->has('fruit'));
$this->tester->assertFalse($arrayer->has('something-else'));
}
示例2: testValidTimestamps
public function testValidTimestamps()
{
foreach ($this->good_timestamps as $good) {
$this->modelWValidation->start_date = $good;
$this->tester->assertTrue($this->modelWValidation->save(), implode('|', $this->modelWValidation->getMessages()));
}
}
示例3: testValidDates
public function testValidDates()
{
foreach ($this->good_dates as $good) {
$this->modelWValidation->date_birth = $good;
$this->tester->assertTrue($this->modelWValidation->save(), implode('|', $this->modelWValidation->getMessages()));
}
}
示例4: testGetAndSetParams
public function testGetAndSetParams()
{
$this->request->setParams(array('name' => 'LeChuck', 'occupation' => 'Ghost Pirate'));
$params = $this->request->getParams();
$this->tester->assertTrue(is_array($params));
$this->tester->assertTrue(count($params) == 2);
$this->tester->assertEquals($params['name'], 'LeChuck');
}
示例5: testGenerate
public function testGenerate()
{
$xml = simplexml_load_file(Yii::getAlias('@data') . '/mts_report.xml', MTSXML::className());
$report = Report::generate($xml);
$this->tester->assertTrue($report instanceof Report);
//codecept_debug(ReportSearch::getOperatorItems());
//$report = new Report();
//codecept_debug( Yii::$app->formatter->asDate(mktime(null,null,null,1,1,2015),'LLLL yyyy'));
//codecept_debug();
//Report::find();
}
示例6: testUndefinedRoute
public function testUndefinedRoute()
{
$route = new router\Container();
$exception = null;
try {
$route->route('undefined/route');
} catch (ErrorException $e) {
$exception = $e;
} finally {
$this->tester->assertTrue($exception instanceof router\NotFound);
}
}
示例7: testCreateJobBadDataJob
/**
* Test print joba
* @param \UnitTester $I
*/
public function testCreateJobBadDataJob(\UnitTester $I)
{
$I->impersonate();
$data = array('podatek' => 'napakaPriPreverjanjuPodatkov');
$metadata = array('name' => 'Testni job', 'task' => '\\TestAssets\\Task\\DummyTestTask', 'data' => $data);
try {
$job = $this->jm->createJob($metadata);
$I->assertTrue(false, "pričakoval napako, pa je ni");
} catch (BadTaskDataException $e) {
$I->assertTrue($e instanceof BadTaskDataException);
}
}
示例8: assertExceptionThrown
private function assertExceptionThrown($callback)
{
$exceptionTrown = false;
try {
$callback();
} catch (Exception $ex) {
$exceptionTrown = true;
}
$this->tester->assertTrue($exceptionTrown);
}
示例9: tryToCompareDifferentChunks
public function tryToCompareDifferentChunks(UnitTester $I)
{
/** @var \Modvert\Resource\Modx\Chunk $r1 */
/** @var \Modvert\Resource\Modx\Chunk $r2 */
$r1 = $I->createChunk();
$r2 = $I->createChunk();
$d2 = $r2->getData();
$d2['snippet'] = '<header>Another header stripe</header>';
$r2->setData($d2);
$ch = \Modvert\Comparator\ComparatorFactory::get(\Modvert\Resource\ResourceType::CHUNK)->compare($r1, $r2);
$I->assertTrue($ch);
}
示例10: assertSubscriptionFormat
private function assertSubscriptionFormat(UnitTester $I, $subscriptions)
{
foreach ($subscriptions as $subscription) {
$I->assertTrue(isset($subscription['id']), "Bill ID");
$I->assertTrue(isset($subscription['status']), "Bill status");
$I->assertTrue(isset($subscription['uri']), "Bill URI");
}
}
示例11: UnitTester
<?php
$I = new UnitTester($scenario);
$I->wantTo('add member');
$app = \Slim\Slim::getInstance();
$app->container->singleton("CreateNewMemberService", function () use($app) {
$member_repo = \Codeception\Util\Stub::make("\\Mabes\\Entity\\MemberRepository", ["save" => function () {
return true;
}]);
$validator = $app->container->get("Validator");
$event_emitter = \Codeception\Util\Stub::make("\\Evenement\\EventEmitter", ["emit" => function () {
return true;
}]);
return new Mabes\Service\CreateMemberService($member_repo, $validator, $event_emitter);
});
// test
$data = ["account_id" => "123", "email" => "john@doe.net", "phone" => "123456789", "fullname" => "John Doe", "bank_name" => "BCA", "account_number" => "123456789", "account_holder" => "John Doe", "address" => "55335 Corwin Rd # A970289, Elkhart, Indiana 46514, USA"];
$command = new \Mabes\Service\Command\CreateMemberCommand();
$command->massAssignment($data);
$create_member_service = $app->container->get("CreateNewMemberService");
$I->assertTrue($create_member_service->execute($command));
示例12: testCategories
public function testCategories()
{
// 1. Add category taxonomy
$taxonomy = new TaxonomyDef();
$taxonomy->name = 'test_categories';
$taxonomy->class = CategoryTerm::className();
$taxonomy->data_table = 'sample_categories';
$taxonomy->ref_table = SampleTable::className();
// 2. Create data table
$categoryTerm = Yii::createObject($taxonomy->attributes);
$migration = $categoryTerm->install();
$this->runMigration($migration);
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name);
$this->tester->assertTrue($categoryTerm->isInstalled(), 'The taxonomy must be installed.');
// 3. Add a root category without an object id
$rootTermName = 'root';
$categoryTerm->addTerm(null, [$rootTermName]);
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name, true);
$rootTerm = $categoryTerm->getTaxonomyTerm($rootTermName);
$terms = $categoryTerm->getTerms(null);
// Check whether everything is properly inserted
$this->tester->assertEquals(0, $categoryTerm->total_count);
$this->tester->assertEquals(0, $rootTerm->total_count);
$this->tester->assertEquals(1, count($terms));
$this->tester->assertEquals($rootTermName, $terms[0]);
// Check for parents
$this->tester->assertNull($categoryTerm->getParent($terms[0]));
$this->tester->assertFalse($categoryTerm->hasParent($terms[0]));
// Check for children
$this->tester->assertEmpty($categoryTerm->getChildren($terms[0]));
$this->tester->assertFalse($categoryTerm->hasChildren($terms[0]));
// 4. Add child to the root
$childTermName1 = 'child1';
$categoryTerm->addTerm(null, [$rootTermName => $childTermName1]);
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name, true);
$childTerm1 = $categoryTerm->getTaxonomyTerm($childTermName1);
$terms = $categoryTerm->getTerms(null);
// Check whether everything is properly inserted
$this->tester->assertEquals(0, $categoryTerm->total_count);
$this->tester->assertEquals(0, $childTerm1->total_count);
$this->tester->assertEquals(2, count($terms));
$this->tester->assertContains($childTermName1, $terms);
// Check for parents
$this->tester->assertTrue($categoryTerm->hasParent($childTermName1));
$this->tester->assertEquals($rootTermName, $categoryTerm->getParent($childTermName1));
// Check for children
$this->tester->assertEmpty($categoryTerm->getChildren($childTermName1));
$this->tester->assertFalse($categoryTerm->hasChildren($childTermName1));
// Check the children of the root
$rootChildren = $categoryTerm->getChildren($rootTermName);
$this->tester->assertTrue($categoryTerm->hasChildren($rootTermName));
$this->tester->assertEquals(1, count($rootChildren));
$this->tester->assertContains($childTermName1, $rootChildren);
// 5. Test adding more than one child at a time
$childTermName2 = 'child2';
$childTermName3 = 'child3';
$categoryTerm->addTerm(null, [$rootTermName => [$childTermName2, $childTermName3]]);
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name, true);
$terms = $categoryTerm->getTerms(null);
// Test whether all child terms are attached to the root
$this->tester->assertEquals(4, count($terms));
$this->tester->assertEquals(3, count($categoryTerm->getChildren($rootTermName)));
// 6. Test adding term to an existing object
$rootTermName2 = 'root2';
$categoryTerm->addTerm(1, $rootTermName2);
// Add a term as a string, not as an array
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name, true);
$rootTerm2 = $categoryTerm->getTaxonomyTerm($rootTermName2);
// Check whether everything is properly inserted
$terms = $categoryTerm->getTerms(1);
$this->tester->assertEquals(1, count($terms));
$this->tester->assertContains($rootTermName2, $terms);
// Check the counters
$this->tester->assertEquals(1, $categoryTerm->total_count);
$this->tester->assertEquals(1, $rootTerm2->total_count);
// Check whether all terms will be returned
$terms = $categoryTerm->getTerms(null);
$this->tester->assertEquals(5, count($terms));
// Add child
$childTermName4 = 'child4';
$categoryTerm->addTerm(1, [$rootTermName2 => $childTermName4]);
$categoryTerm = $this->getTaxonomy()->getTerm($taxonomy->name, true);
$rootTerm2 = $categoryTerm->getTaxonomyTerm($rootTermName2);
$childTerm4 = $categoryTerm->getTaxonomyTerm($childTermName4);
$terms = $categoryTerm->getTerms(1);
$this->tester->assertEquals(2, count($terms));
$this->tester->assertEquals(2, $categoryTerm->total_count);
$this->tester->assertEquals(1, $rootTerm2->total_count);
$this->tester->assertEquals(1, $childTerm4->total_count);
// 7. Loop detection test. Add the root as a child of one of the children
$exceptionTrown = false;
try {
$categoryTerm->addTerm(null, [$childTermName3 => $rootTermName]);
} catch (Exception $ex) {
$exceptionTrown = true;
}
$this->tester->assertTrue($exceptionTrown);
// 8. Adding two hierarchies at once
TaxonomyTerms::deleteAll();
$categoryTerm->addTerm(null, [$rootTermName => [$childTermName1, $childTermName2], $rootTermName2]);
//.........这里部分代码省略.........
示例13: tryToCreateStorage
public function tryToCreateStorage(UnitTester $I)
{
$storage = new \Modvert\Storage($I->getConnection());
$I->assertTrue($storage instanceof \Modvert\Storage);
}
示例14: UnitTester
<?php
$I = new UnitTester($scenario);
$I->wantTo('auth staff');
$app = \Slim\Slim::getInstance();
$app->container->singleton("AuthService", function () use($app) {
$hash_service = new \Mabes\Service\HashService("1234");
$hash = $hash_service->hash();
$staff_repo = \Codeception\Util\Stub::make("\\Mabes\\Entity\\StaffRepository", ["findOneBy" => function () use($hash) {
$staff = new \Mabes\Entity\Staff();
$staff->setPassword($hash);
return $staff;
}, "save" => function () {
return true;
}]);
$event_emitter = \Codeception\Util\Stub::make("\\Evenement\\EventEmitter", ["emit" => function () {
return true;
}]);
$auth_password = \Codeception\Util\Stub::make("Mabes\\Service\\AuthPasswordService");
$validator = $app->container->get("Validator");
return new \Mabes\Service\AuthService($staff_repo, $auth_password, $validator, $event_emitter);
});
$data = ["username" => "john", "password" => "1234"];
$command = new \Mabes\Service\Command\AuthCommand();
$command->massAssignment($data);
$service = $app->container->get("AuthService");
$I->assertTrue($service->execute($command));
// EOF
示例15: holiday
<?php
use mole\helpers\Datetime;
function holiday($year, array $include = [], array $exclude = [])
{
$stamp = strtotime(sprintf('%s-01-01', $year));
$result = [];
do {
if (date('w', $stamp) == 0 || date('w', $stamp) == 6) {
$result[] = date('Y-m-d', $stamp);
}
$stamp = strtotime('+1 day', $stamp);
if ((int) date('Y', $stamp) > 2016) {
break;
}
} while (true);
$result = array_merge($result, $include);
$result = array_diff($result, $exclude);
sort($result);
return $result;
}
$I = new UnitTester($scenario);
$I->wantTo('perform actions and see result');
$I->assertTrue(holiday('2016', ['2016-06-12'], ['2016-06-09', '2016-06-10']) == Datetime::holiday('2016', ['2016-06-12'], ['2016-06-09', '2016-06-10']));