PHP'nin SimpleTest tomfoolery.

0 Cevap php

Ancak deneme başarısız olur ve "Fatal error: Call to a member function fetchAll() on a non-object in C:\xampp\htdocs\Call log\tests\model_tests.php on line 13." Açıkçası, bu doğru olamaz bana hata veriyor, ben basit bir Datamapper sınıf için bir test yazıyorum ve ben yöntemi çalıştığını biliyorum çünkü ben yöntem çalıştığını doğrulayın.

İşte sözde üzerinde erroring oluyor kodu:

function all() {
    $calls = $this->pdo->query('SELECT * from calls');
    return $calls->fetchAll();
}

İşte benim test kodu:

class TestOfCallMapper extends UnitTestCase {
    function testOfReturnsAll() {
        $this->createSchema();
        $mapper = Callmapper::getInstance();
        $results = $mapper->all();
        print_r($results);
    }

    private function createSchema() {
        $mapper = CallMapper::getInstance();
        $mapper->pdo->exec(file_get_contents('../database/create_schema.sql'));
    }

    private function destroySchema() {
        $mapper = CallMapper::getInstance();
        $mapper->pdo->exec(file_get_contents('../database/destroy_schema.sql'));
    }
}

$test = new TestOfCallMapper('Test of CallMapper Methods');
$test->run(new HTMLReporter());

Eğer bunu yaparsam, gayet güzel çalışıyor:

    $mapper = CallMapper::getInstance();
    $test = $mapper->all();
    print_r($test->fetchAll());

0 Cevap