<commit_before><?php
/*
 * This file is part of wulacms.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace tests\Tests\common;

use PHPUnit\Framework\TestCase;

/**
 * Class CommonFuncsTest
 * @package tests\Tests\common
 * @group   common
 */
class CommonFuncsTest extends TestCase {
    public function testGet_then_unset() {
        $ary  = ['name' => 'wula', 'name1' => 'wula1'];
        $name = get_then_unset($ary, 'name');
        self::assertArrayNotHasKey('name', $ary);
        self::assertArrayHasKey('name1', $ary);
        self::assertArrayHasKey('name', $name);
        self::assertEquals('wula', $name['name']);
    }

    public function testUnique_filename() {
        $f1 = unique_filename(TMP_PATH, 'test.txt');
        self::assertEquals('test.txt', $f1);
        self::assertTrue(@file_put_contents(TMP_PATH . 'test.txt', 'test') > 0);
        $f2 = unique_filename(TMP_PATH, 'test.txt');
        self::assertEquals('test1.txt', $f2);
        @unlink(TMP_PATH . 'test.txt');
    }

    public function testPure_comman_string() {
        $string = pure_comman_string('a,,b,,，c,   d,中国');
        self::assertEquals('a,b,c,d,中国', $string);
    }
}<commit_msg>创建tmp目录<commit_after><?php
/*
 * This file is part of wulacms.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace tests\Tests\common;

use PHPUnit\Framework\TestCase;

/**
 * Class CommonFuncsTest
 * @package tests\Tests\common
 * @group   common
 */
class CommonFuncsTest extends TestCase {
    public function testGet_then_unset() {
        $ary  = ['name' => 'wula', 'name1' => 'wula1'];
        $name = get_then_unset($ary, 'name');
        self::assertArrayNotHasKey('name', $ary);
        self::assertArrayHasKey('name1', $ary);
        self::assertArrayHasKey('name', $name);
        self::assertEquals('wula', $name['name']);
    }

    public function testUnique_filename() {
        if (!is_dir(TMP_PATH)) {
            self::assertTrue(mkdir(TMP_PATH, 0755));
        }
        $f1 = unique_filename(TMP_PATH, 'test.txt');
        self::assertEquals('test.txt', $f1);
        self::assertTrue(@file_put_contents(TMP_PATH . 'test.txt', 'test') > 0);
        $f2 = unique_filename(TMP_PATH, 'test.txt');
        self::assertEquals('test1.txt', $f2);
        @unlink(TMP_PATH . 'test.txt');
    }

    public function testPure_comman_string() {
        $string = pure_comman_string('a,,b,,，c,   d,中国');
        self::assertEquals('a,b,c,d,中国', $string);
    }

    public static function tearDownAfterClass() {
        @unlink(TMP_PATH);
    }
}
{'fraction_non_alphanumeric': 0.16258111031002162, 'fraction_numerical': 0.007930785868781542, 'mean_word_length': 3.262672811059908, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1352990', 'n_tokens_mistral': 917, 'n_tokens_neox': 922, 'n_words': 187}