public function tearDown() { $stmt = $this->pdo->prepare('DROP DATABASE IF EXISTS `DbMockLibraryTest`'); $stmt->execute(); if (MySQL::getInstance()) { MySQL::getInstance()->destroy(); } }
/** * @return void */ public function test_function() { // prepare $stmt = $this->pdo->prepare('SELECT * FROM `DbMockLibraryTest`.testTable WHERE `id` = 0'); $stmt->execute(); $result = $stmt->fetchAll(); $reflection = new \ReflectionClass(MySQL::getInstance()); $deleteMethod = $reflection->getMethod('delete'); $deleteMethod->setAccessible(true); // test $this->assertCount(1, $result); // invoke logic $deleteMethod->invoke(MySQL::getInstance(), 'testTable', 1); // prepare $stmt->execute(); $result = $stmt->fetchAll(); // test $this->assertCount(0, $result); }