<commit_before><?php namespace Schuppo\PasswordStrength;

use \Symfony\Component\Translation\Translator;
use  \Illuminate\Validation\Factory;
/**
 * PasswordStrengthTest
 *
 * @group validators
 */
class PasswordStrengthTest extends \PHPUnit_Framework_TestCase
{

    public function setUp()
    {
        $this->factory = new Factory(new Translator('en'));
        $pS = new PasswordStrength();
        $this->factory->extend('case_diff', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateCaseDiff($attribute, $value, $parameters);
        });
        $this->factory->extend('numbers', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateNumbers($attribute, $value, $parameters);
        });
        $this->factory->extend('letters', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateLetters($attribute, $value, $parameters);
        });
    }

    public function test_case_diff_fails_just_lowercase()
    {
        $this->validation = $this->factory->make(['password' => 'tt'], ['password' => '<PASSWORD>'] );
        $this->assertFalse($this->validation->passes());
    }

    public function test_case_diff_fails_just_uppercase()
    {
       $this->validation = $this->factory->make(['password' => 'TT'], ['password' => '<PASSWORD>'] );
        $this->assertFalse($this->validation->passes());
    }

    public function test_case_diff_succeeds()
    {
        $this->validation = $this->factory->make(['password' => 'Tt'], ['password' => '<PASSWORD>'] );


        $this->assertTrue($this->validation->passes());
    }

    public function test_numbers_fails()
    {
        $this->validation = $this->factory->make(['password' => 'T'], ['password' => 'numbers'] );

        $this->assertFalse($this->validation->passes());
    }

    public function test_numbers_succeeds()
    {
        $this->validation = $this->factory->make(['password' => '1'], ['password' => 'numbers'] );

        $this->assertTrue($this->validation->passes());
    }

    public function test_letters_fails()
    {
        $this->validation = $this->factory->make(['password' => '1'], ['password' => '<PASSWORD>'] );

        $this->assertFalse($this->validation->passes());
    }

    public function test_letters_succeeds()
    {
        $this->validation = $this->factory->make(['password' => 'T'], ['password' => '<PASSWORD>'] );

        $this->assertTrue($this->validation->passes());
    }

    public function test_custom_validation_errors_are_not_overwritten()
    {
        $this->validation = $this->factory->make(['password' => ''], ['password' => '<PASSWORD>'], ['required' => 'Should not be overwritten.']);

        $this->assertEquals('Should not be overwritten.', $this->validation->errors()->get('password')[0]);
    }
}<commit_msg>changed the unit test<commit_after><?php namespace Schuppo\PasswordStrength;

use \Symfony\Component\Translation\Translator;
use  \Illuminate\Validation\Factory;
/**
 * PasswordStrengthTest
 *
 * @group validators
 */
class PasswordStrengthTest extends \PHPUnit_Framework_TestCase
{

    public function setUp()
    {
        $this->factory = new Factory(new Translator('en'));
        $pS = new PasswordStrength();
        $this->factory->extend('case_diff', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateCaseDiff($attribute, $value, $parameters);
        });
        $this->factory->extend('numbers', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateNumbers($attribute, $value, $parameters);
        });
        $this->factory->extend('letters', function($attribute, $value, $parameters) use ($pS){
            return $pS->validateLetters($attribute, $value, $parameters);
        });
    }

    public function test_case_diff_fails_just_lowercase()
    {
        $this->validation = $this->factory->make(
            array( 'password' => 'tt' ),
            array( 'password' => '<PASSWORD>' )
        );
        $this->assertFalse($this->validation->passes());
    }

    public function test_case_diff_fails_just_uppercase()
    {
       $this->validation = $this->factory->make(
            array( 'password' => 'TT' ),
            array( 'password' => '<PASSWORD>')
        );
        $this->assertFalse($this->validation->passes());
    }

    public function test_case_diff_succeeds()
    {
        $this->validation = $this->factory->make(
            array( 'password' => 'Tt' ),
            array( 'password' => '<PASSWORD>')
        );


        $this->assertTrue($this->validation->passes());
    }

    public function test_numbers_fails()
    {
        $this->validation = $this->factory->make(
            array( 'password' => 'T' ),
            array( 'password' => '<PASSWORD>' )
        );

        $this->assertFalse($this->validation->passes());
    }

    public function test_numbers_succeeds()
    {
        $this->validation = $this->factory->make(
            array( 'password' => '1' ),
            array( 'password' => '<PASSWORD>' )
        );

        $this->assertTrue($this->validation->passes());
    }

    public function test_letters_fails()
    {
        $this->validation = $this->factory->make(
            array( 'password' => '1' ),
            array( 'password' => '<PASSWORD>' )
        );

        $this->assertFalse($this->validation->passes());
    }

    public function test_letters_succeeds()
    {
        $this->validation = $this->factory->make(
            array( 'password' => 'T' ),
            array( 'password' => '<PASSWORD>')
        );

        $this->assertTrue($this->validation->passes());
    }

    public function test_custom_validation_errors_are_not_overwritten()
    {
        $this->validation = $this->factory->make(
            array( 'password' => '' ),
            array( 'password' => '<PASSWORD>' ),
            array( 'required' => 'Should not be overwritten.' )
        );

        $errorArray = $this->validation->errors()->get('password');
        $this->assertEquals('Should not be overwritten.', $errorArray[0]);
    }
}
{'fraction_non_alphanumeric': 0.18187765783447823, 'fraction_numerical': 0.0009813542688910696, 'mean_word_length': 2.887476160203433, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 169, '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': '2977625', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1733, 'n_words': 298}