KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/irtiweb/CATS/src/OpenCATS/Tests/IntegrationTests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/irtiweb/CATS/src/OpenCATS/Tests/IntegrationTests/DatabaseTestCase.php
<?php
namespace OpenCATS\Tests\IntegrationTests;

use PHPUnit\Framework\TestCase;

class DatabaseTestCase extends TestCase
{
    private $connection;

    function setUp()
    {
        global $mySQLConnection;
        parent::setUp();
        include_once('./constants.php');
        define('DATABASE_NAME', 'cats_integrationtest');
        define('DATABASE_HOST', 'integrationtestdb');

        include_once('./config.php');
        include_once('./lib/DatabaseConnection.php');
        $mySQLConnection = @mysql_connect(
            DATABASE_HOST, DATABASE_USER, DATABASE_PASS
            );
        if (!$mySQLConnection)
        {
            throw new \Exception('Error connecting to the mysql server');
        }
        $this->mySQLQuery('DROP DATABASE IF EXISTS ' . DATABASE_NAME);
        $this->mySQLQuery('CREATE DATABASE ' . DATABASE_NAME);

        @mysql_select_db(DATABASE_NAME, $mySQLConnection);

        $this->mySQLQueryMultiple(file_get_contents('db/cats_schema.sql'), ";\n");
    }

    // TODO: remove duplicated code
    private function MySQLQueryMultiple($SQLData, $delimiter = ';')
    {
        $SQLStatments = explode($delimiter, $SQLData);

        foreach ($SQLStatments as $SQL)
        {
            $SQL = trim($SQL);

            if (empty($SQL))
            {
                continue;
            }

            $this->mySQLQuery($SQL);
        }
    }

    private function mySQLQuery($query, $ignoreErrors = false)
    {
        global $mySQLConnection;

        $queryResult = mysql_query($query, $mySQLConnection);
        if (!$queryResult && !$ignoreErrors)
        {
            $error = mysql_error($mySQLConnection);

            if ($error == 'Query was empty')
            {
                return $queryResult;
            }

            die (
                '<p style="background: #ec3737; padding: 4px; margin-top: 0; font:'
                . ' normal normal bold 12px/130% Arial, Tahoma, sans-serif;">Query'
                . " Error -- Please Report This Bug!</p><pre>\n\nMySQL Query "
                . "Failed: " . $error . "\n\n" . $query . "</pre>\n\n"
                );
        }

        return $queryResult;
    }


    function tearDown()
    {
        $this->mySQLQuery('DROP DATABASE IF EXISTS ' . DATABASE_NAME);
    }
}
?>

Anon7 - 2021