class core_phpunit_basic_testcase extends basic_testcase {
protected $testassertexecuted = false;
- public function setUp() {
+ protected function setUp() {
+ parent::setUp();
if ($this->getName() === 'test_setup_assert') {
$this->assertTrue(true);
$this->testassertexecuted = true;
* @return void
*/
public function test_assert_behaviour() {
- // arrays
+ // Arrays.
$a = array('a', 'b', 'c');
$b = array('a', 'c', 'b');
$c = array('a', 'b', 'c');
$this->assertEquals($a, $c);
$this->assertEquals($a, $b, '', 0, 10, true);
- // objects
+ // Objects.
$a = new stdClass();
$a->x = 'x';
$a->y = 'y';
- $b = new stdClass(); // switched order
+ $b = new stdClass(); // Switched order.
$b->y = 'y';
$b->x = 'x';
$c = $a;
$this->assertSame($a, $c);
$this->assertNotEquals($a, $d);
- // string comparison
+ // String comparison.
$this->assertEquals(1, '1');
$this->assertEquals(null, '');
$this->assertNotEquals(null, '0');
$this->assertNotEquals(array(), '');
- // other comparison
+ // Other comparison.
$this->assertEquals(null, null);
$this->assertEquals(false, null);
$this->assertEquals(0, null);
- // emptiness
+ // Emptiness.
$this->assertEmpty(0);
$this->assertEmpty(0.0);
$this->assertEmpty('');
$this->testassertexecuted = false;
}
-// Uncomment following tests to see logging of unexpected changes in global state and database
+ // Uncomment following tests to see logging of unexpected changes in global state and database.
/*
public function test_db_modification() {
global $DB;