本文整理汇总了PHP中UnitTester::assertNull方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTester::assertNull方法的具体用法?PHP UnitTester::assertNull怎么用?PHP UnitTester::assertNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTester
的用法示例。
在下文中一共展示了UnitTester::assertNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetSetReport
public function testGetSetReport()
{
$task = new PhpcsLintFiles();
$this->tester->assertNull($task->getReport('full'), 'default value');
$task = new PhpcsLintFiles(['reports' => ['full' => 'a']]);
$this->tester->assertEquals('a', $task->getReport('full'), 'set in constructor');
$task->setReport('full', 'b');
$this->tester->assertEquals('b', $task->getReport('full'), 'normal');
}
示例2: testConstructor
public function testConstructor()
{
$metric = new Metric('testname');
$this->tester->assertEquals('testname', $metric->getName(), 'Metric::Constructor failed!');
$this->tester->assertNull($metric->getNamespace(), 'Metric::Constructor failed!');
$this->tester->assertNull($metric->getUnit(), 'Metric::Constructor failed!');
$this->tester->assertNull($metric->getValue(), 'Metric::Constructor failed!');
$metric = new Metric('testname', 'Count', '1', 'testns');
$this->tester->assertEquals('testname', $metric->getName(), 'Metric::Constructor failed!');
$this->tester->assertEquals('Count', $metric->getUnit(), 'Metric::Constructor failed!');
$this->tester->assertEquals('1', $metric->getValue(), 'Metric::Constructor failed!');
$this->tester->assertEquals('testns', $metric->getNamespace(), 'Metric::Constructor failed!');
}
示例3: testInvalidGetRawDataValue
public function testInvalidGetRawDataValue()
{
$this->tester->assertNull($this->request->getRawData('get', 'non existent value'));
}
示例4: 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]);
//.........这里部分代码省略.........