public function testMain() { $logger = new Logger(); $this->assertFalse($logger->hasLogs(), 'has logs is false'); $logger->add('Start log'); $this->assertContains('Start log', $logger->getLast(), 'getLast default log'); $this->assertCount(1, $logger->getList(), 'getList count is one'); $this->assertTrue($logger->hasLogs(), 'has logs is true'); $logger->add('executing', Logger::NAMESPACE_DB); $this->assertArrayHasKey(Logger::NAMESPACE_DB, $logger->getListWithNamespaces(), 'db record added'); $this->assertEquals('', $logger->getLogsPath(), 'Log folder is empty'); $logsPath = __DIR__ . '/tmp/'; $logger->setLogsPath($logsPath); $this->assertEquals($logsPath, $logger->getLogsPath(), 'Log folder set'); $logger->save(); $this->assertFileExists($logsPath . Logger::NAMESPACE_APPLICATION . '.log', 'application.txt created'); }
/** * Elimina un registro de una tabla. Puede ser eliminacion logica o fisica. */ public function deleteFromTable($tableName, $id, $logical) { if ($logical) { Logger::add(Logger::LEVEL_DAL, "DAL::delete LOGICAL " . __LINE__); $data = array('id' => $id, 'deleted' => true); // No hay que actualizar atributo "class". $this->update_query2($data, $tableName); } else { Logger::add(Logger::LEVEL_DAL, "DAL::delete FISICAL " . __LINE__); $q = "DELETE FROM " . $tableName . " WHERE id=" . $id; $this->db->execute($q); } }