<commit_before><?php
/**
 * php7-mysql-shim
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright 2015 Akamai Technologies, Inc. All rights reserved.
 * @license Apache 2.0
 * @link https://github.com/akamai-open/php7-mysql-shim
 * @link https://developer.akamai.com
 */

namespace Dshafik\MySQL\Tests;

class MySqlShimTest extends \PHPUnit_Framework_TestCase
{
    static $host;
    static $container;
    static $bin = [];

    protected $runtime;

    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->runtime = new \SebastianBergmann\Environment\Runtime();
    }

    public function test_mysql_connect()
    {
        $mysql = mysql_connect(static::$host, 'root');
        $this->assertConnection($mysql);
    }

    /**
     * @requires PHP 7
     */
    public function test_mysql_connect_defaults()
    {
        ini_set('mysqli.default_host', '127.0.0.1');
        ini_set('mysqli.default_user', 'root');
        ini_set('mysqli.default_pw', '');

        $mysql = mysql_connect();
        $this->assertConnection($mysql);
    }

    /**
     * @expectedException \PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessageRegExp /^mysql(i?)_connect\(\): (\(HY000\/1045\): )?Access denied for user 'baduser'@'(.*?)' \(using password: YES\)$/
     */
    public function test_mysql_connect_fail()
    {
        $mysql = mysql_connect(static::$host, "baduser", "badpass");
    }

    /**
     * @expectedException \PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessage Argument $new is no longer supported in PHP > 7
     * @requires PHP 7.0.0<commit_msg>Test for false when `mysql_connect()` fails<commit_after><?php
/**
 * php7-mysql-shim
 *
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright 2015 Akamai Technologies, Inc. All rights reserved.
 * @license Apache 2.0
 * @link https://github.com/akamai-open/php7-mysql-shim
 * @link https://developer.akamai.com
 */

namespace Dshafik\MySQL\Tests;

class MySqlShimTest extends \PHPUnit_Framework_TestCase
{
    static $host;
    static $container;
    static $bin = [];

    protected $runtime;

    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->runtime = new \SebastianBergmann\Environment\Runtime();
    }

    public function test_mysql_connect()
    {
        $mysql = mysql_connect(static::$host, 'root');
        $this->assertConnection($mysql);
    }

    /**
     * @requires PHP 7
     */
    public function test_mysql_connect_defaults()
    {
        ini_set('mysqli.default_host', '127.0.0.1');
        ini_set('mysqli.default_user', 'root');
        ini_set('mysqli.default_pw', '');

        $mysql = mysql_connect();
        $this->assertConnection($mysql);
    }

    /**
     * @expectedException \PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessageRegExp /^mysql(i?)_connect\(\): (\(HY000\/1045\): )?Access denied for user 'baduser'@'(.*?)' \(using password: YES\)$/
     */
    public function test_mysql_connect_fail_warning()
    {
        $mysql = mysql_connect(static::$host, "baduser", "badpass");
    }

    public function test_mysql_connect_fail_false()
    {
        $mysql = @mysql_connect(static::$host, "baduser", "badpass");
        $this->assertFalse($mysql);
    }

    /**
     * @expectedException \PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessage Argument $new is no longer supported in PHP > 7
     * @requires PHP 7.0.0
{'fraction_non_alphanumeric': 0.15065807896947633, 'fraction_numerical': 0.014561747409689163, 'mean_word_length': 3.1010332950631456, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7522819', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1116, 'n_words': 220}