<commit_before><?php

class CM_Migration_GeneratorTest extends CMTest_TestCase {

    public function tearDown() {
        CMTest_TH::clearEnv();
    }

    public function testSave() {
        $tmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp();
        $generator = new CM_Migration_Generator($tmp);
        $time = CMTest_TH::time();
        $file = $generator->save('  foo-bar_baz');

        $path = $file->getPathOnLocalFilesystem();

        $this->assertSame(sprintf('%s_FooBarBaz.php', $time), $file->getFileName());
        $this->assertSame(join(PHP_EOL, [
            '<?php',
            '',
            sprintf('class Migration_%s_FooBarBaz implements \CM_Migration_UpgradableInterface {', $time),
            '',
            '    /**',
            '     * @param CM_OutputStream_Interface $output',
            '     * @return mixed',
            '     */',
            '    public function up(\CM_OutputStream_Interface $output) {',
            '        // TODO: Implement the migration script',
            '    }',
            '}',
            '',
        ]), $file->read());
    }

    public function test_sanitize() {
        $tmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp();
        $generator = new CM_Migration_Generator($tmp);

        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_Bar']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['  fOO_bar']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_bAr']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_bAr']));<commit_msg>Fix CM_Migration_GeneratorTest<commit_after><?php

class CM_Migration_GeneratorTest extends CMTest_TestCase {

    public function tearDown() {
        CMTest_TH::clearEnv();
    }

    public function testSave() {
        $tmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp();
        $generator = new CM_Migration_Generator($tmp);
        $time = CMTest_TH::time();
        $file = $generator->save('  foo-bar_baz');

        $path = $file->getPathOnLocalFilesystem();

        $this->assertSame(sprintf('%s_FooBarBaz.php', $time), $file->getFileName());
        $this->assertSame(join(PHP_EOL, [
            '<?php',
            '',
            sprintf('class Migration_%s_FooBarBaz implements \CM_Migration_UpgradableInterface {', $time),
            '',
            '    ',
            '    public function up(\CM_OutputStream_Interface $output) {',
            '        // TODO: Implement the migration script',
            '    }',
            '}',
            '',
        ]), $file->read());
    }

    public function test_sanitize() {
        $tmp = CM_Service_Manager::getInstance()->getFilesystems()->getTmp();
        $generator = new CM_Migration_Generator($tmp);

        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_Bar']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['  fOO_bar']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_bAr']));
        $this->assertSame('FooBar', CMTest_TH::callProtectedMethod($generator, '_sanitize', ['foo_bAr']));
{'fraction_non_alphanumeric': 0.16308884913536076, 'fraction_numerical': 0.0, 'mean_word_length': 2.878612716763006, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '2130769', 'n_tokens_mistral': 988, 'n_tokens_neox': 986, 'n_words': 141}