<commit_before><?php

namespace Tests\AppBundle\Entity;

use AppBundle\Entity\CasRec;
use AppBundle\Entity\Report\Report;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="casrec")
 * @ORM\Entity
 */
class CasRecTest extends \PHPUnit_Framework_TestCase
{
    public static function normalizeSurnameProvider()
    {
        return [
            ['', ''],
            ['  ', ''],
            [' A !@£$1%^&*(   b!{}"| ', 'a1b'],
            [null, null],
            ['PELL M B E ', 'pell'],
            [' COGGINGS MBE ', 'coggings'],
            ["<NAME>", 'dsouzagair'],
            ['KNIGHT- PREISS', 'knightpreiss'],
            ['PHIPPS - THE MARQUIS OF NORMANBY', 'phippsthemarquisofnormanby'],
            // accent conversion
            ['<NAME>', 'villanuevacortes'],
            ['<NAME>', 'nifhatharta'],
            [' Müller ', 'muller'],
        ];
    }

    /**
     * @dataProvider  normalizeSurnameProvider
     */
    public function testnormaliseSurname($input, $expected)
    {
        $this->assertEquals($expected, CasRec::normaliseSurname($input));
    }

    public static function normaliseCaseNumberProvider()
    {
        return [
            ['   12345678   ', '12345678'],
            [' 1234567T ', '1234567t'],
        ];
    }

    /**
     * @dataProvider normaliseCaseNumberProvider
     */
    public function testnormaliseCaseNumber($input, $expected)
    {
        $this->assertEquals($expected, CasRec::normaliseDeputyNo($input));
    }

    public function getTypeBasedOnTypeofRepAndCorrefProvider()
    {
        return [
            //corref, type of rep, expected created report

            // 103 created with L3(G) - OPG103
            ['l3', 'opg103', Report::ENABLE_103 ? Report::TYPE_103 : Report::TYPE_102],
            ['l3g', 'opg103', Report::ENABLE_103 ? Report::TYPE_103 : Report::TYPE_102],

            // 104 create with
            ['hw', '', Report::ENABLE_104 ? Report::TYPE_104 : Report::TYPE_102],

            // all the rest is a 102 (default)
            [null, null, Report::TYPE_102],
            [null, 'opg103', Report::TYPE_102],
            [null, 'opg103', Report::TYPE_102],
            ['l2', 'opg103', Report::TYPE_102],
            ['hw', 'opg103', Report::TYPE_102],
            ['hw', 'opg102', Report::TYPE_102],
        ];
    }

    /**
     * @dataProvider getTypeBasedOnTypeofRepAndCorrefProvider
     */
    public function testgetTypeBasedOnTypeofRepAndCorref($corref, $typeOfRep, $expectedType)
    {
        $this->assertEquals($expectedType, CasRec::getTypeBasedOnTypeofRepAndCorref($typeOfRep, $corref));
    }<commit_msg>DDPB-1239-report-type-csv-updated add test cases a3<commit_after><?php

namespace Tests\AppBundle\Entity;

use AppBundle\Entity\CasRec;
use AppBundle\Entity\Report\Report;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="casrec")
 * @ORM\Entity
 */
class CasRecTest extends \PHPUnit_Framework_TestCase
{
    public static function normalizeSurnameProvider()
    {
        return [
            ['', ''],
            ['  ', ''],
            [' A !@£$1%^&*(   b!{}"| ', 'a1b'],
            [null, null],
            ['PELL M B E ', 'pell'],
            [' COGGINGS MBE ', 'coggings'],
            ["D'SOUZA GAIR", 'dsouzagair'],
            ['KNIGHT- PREISS', 'knightpreiss'],
            ['PHIPPS - THE MARQUIS OF NORMANBY', 'phippsthemarquisofnormanby'],
            // accent conversion
            ['<NAME>', 'villanuevacortes'],
            ['<NAME>', 'nifhatharta'],
            [' Müller ', 'muller'],
        ];
    }

    /**
     * @dataProvider  normalizeSurnameProvider
     */
    public function testnormaliseSurname($input, $expected)
    {
        $this->assertEquals($expected, CasRec::normaliseSurname($input));
    }

    public static function normaliseCaseNumberProvider()
    {
        return [
            ['   12345678   ', '12345678'],
            [' 1234567T ', '1234567t'],
        ];
    }

    /**
     * @dataProvider normaliseCaseNumberProvider
     */
    public function testnormaliseCaseNumber($input, $expected)
    {
        $this->assertEquals($expected, CasRec::normaliseDeputyNo($input));
    }

    public function getTypeBasedOnTypeofRepAndCorrefProvider()
    {
        return [
            //corref, type of rep, expected created report

            // 103 created with L3(G) - OPG103
            ['l3', 'opg103', Report::ENABLE_103 ? Report::TYPE_103 : Report::TYPE_102],
            ['l3g', 'opg103', Report::ENABLE_103 ? Report::TYPE_103 : Report::TYPE_102],
            ['a3', 'opg103', Report::ENABLE_103 ? Report::TYPE_103 : Report::TYPE_103],

            // 104 create with
            ['hw', '', Report::ENABLE_104 ? Report::TYPE_104 : Report::TYPE_102],

            // other cases
            [null, null, Report::TYPE_102],
            [null, 'opg103', Report::TYPE_102],
            [null, 'opg103', Report::TYPE_102],
            ['l3', 'whatever', Report::TYPE_102],
            ['l3g', 'whatever', Report::TYPE_102],
            ['a3', 'whatever', Report::TYPE_102],
            ['l2', 'opg103', Report::TYPE_102],
            ['hw', 'opg103', Report::TYPE_102],
            ['hw', 'opg102', Report::TYPE_102],
        ];
    }

    /**
     * @dataProvider getTypeBasedOnTypeofRepAndCorrefProvider
     */
    public function testgetTypeBasedOnTypeofRepAndCorref($corref, $typeOfRep, $expectedType)
    {
        $this->assertEquals($expectedType, CasRec::getTypeBasedOnTypeofRepAndCorref($typeOfRep, $corref));
    }
{'fraction_non_alphanumeric': 0.15409776485553334, 'fraction_numerical': 0.04633836089405779, 'mean_word_length': 2.3438639125151886, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, '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': '5548297', 'n_tokens_mistral': 1884, 'n_tokens_neox': 1674, 'n_words': 310}