Question

I'm new to php and I'm writing a test function to test a class I have already written. However, I'm not sure how I should properly make a call to the function assertTrue().

Here is the code I have:

    <?php
    require_once(dirname(__FILE__) . '/simpletest/autorun.php');
    require_once('../db/fileToBeTested.php');

class TestDbManager extends UnitTestCase {

    function TestDbManager(){
        $this->UnitTestCase("Test DB Manager");
    }

    // Function to test if isTableExisting() method works correctly
    function testIsTableExisting() {
        $testDB = new DB("localhost", "root", "password", "GraphAppDB", "3306", "empty@empty.com", true, "GraphApp")
        $this->assertTrue($testDB->isTableExisting("users"), "users table exists");
        $this->assertFalse($testDB->isTableExisting("notAValidTable"), "notAValidTable does not exist");
        $this->assertFalse($testDB->isTableExisting(""));   
    }
}
?>

And here is the error I am getting:

Parse error: syntax error, unexpected '$this' (T_VARIABLE) in /Applications/XAMPP/xamppfiles/htdocs/GraphApp/tests/TestDbManager.php on line 14

Was it helpful?

Solution

You're missing a ; after

$testDB = new DB("localhost", "root", "password", "GraphAppDB", "3306", "empty@empty.com", true, "GraphApp")

The call to assertTrue is probably fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top