<commit_before><?php
namespace DrdPlus\Exceptionalities;

use Drd\DiceRoll\RollInterface;
use DrdPlus\Exceptionalities\Fates\ExceptionalityFate;
use DrdPlus\Person\ProfessionLevels\ProfessionLevel;
use DrdPlus\Professions\Profession;
use DrdPlus\Properties\Base\Agility;
use DrdPlus\Properties\Base\BasePropertyFactory;
use DrdPlus\Properties\Base\Charisma;
use DrdPlus\Properties\Base\Intelligence;
use DrdPlus\Properties\Base\Knack;
use DrdPlus\Properties\Base\Strength;
use DrdPlus\Properties\Base\Will;
use DrdPlus\Tests\Tools\TestWithMockery;

class ExceptionalityPropertiesFactoryTest extends TestWithMockery
{
    /**
     * @param $strength
     * @param $agility
     * @param $knack
     * @param $will
     * @param $intelligence
     * @param $charisma
     *
     * @test
     * @dataProvider getChosenProperties
     */
    public function I_can_get_chosen_properties_tested_as_primary($strength, $agility, $knack, $will, $intelligence, $charisma)
    {
        $factory = new ExceptionalityPropertiesFactory();

        $chosenProperties = $factory->createChosenProperties(
            $this->createChosenFate(
                $strength + $agility + $knack + $will + $intelligence + $charisma,
                0,
                max($strength, $agility, $knack, $will, $intelligence, $charisma)
            ),
            $this->createProfessionLevel([
                Strength::STRENGTH,
                Agility::AGILITY,
                Knack::KNACK,
                Will::WILL,
                Intelligence::INTELLIGENCE,
                Charisma::CHARISMA,
            ]),
            $strength = $this->createStrength($strength),
            $agility = $this->createAgility($agility),
            $knack = $this->createKnack($knack),
            $will = $this->createWill($will),
            $intelligence = $this->createIntelligence($intelligence),
            $charisma = $this->createCharisma($charisma)
        );
        $this->assertSame($strength, $chosenProperties->getStrength());
        $this->assertSame($agility, $chosenProperties->getAgility());
        $this->assertSame($knack, $chosenProperties->getKnack());
        $this->assertSame($will, $chosenProperties->getWill());
        $this->assertSame($intelligence, $chosenProperties->getIntelligence());
        $this->assertSame($charisma, $chosenProperties->getCharisma());
    }

    public function getChosenProperties()
    {
        return [
            [1, 2, 3, 4, 5, 6],
        ];
    }

    /**
     * @param int $primaryPropertiesBonus
     * @param int $secondaryPropertiesBonus
     * @param int $upToSingleProperty
     * @return ExceptionalityFate
     */
    private function createChosenFate($primaryPropertiesBonus, $secondaryPropertiesBonus, $upToSingleProperty)
    {
        $fate = $this->mockery(ExceptionalityFate::class);
        $fate->shouldReceive('getSecondaryPropertiesBonusOnChoice')
            ->andReturn($secondaryPropertiesBonus);
        $fate->shouldReceive('getPrimaryPropertiesBonusOnChoice')
            ->andReturn($primaryPropertiesBonus);
        $fate->shouldReceive('getUpToSingleProperty')
            ->andReturn($upToSingleProperty);
        $fate->shouldReceive('getCode')
            ->andReturn('foo');

        return $fate;
    }

    /**
     * @param array $primaryPropertyCodes
     * @return ProfessionLevel
     */
    private function createProfessionLevel(array $primaryPropertyCodes)
    {
        $professionLevel = $this->mockery(ProfessionLevel::class);
        $professionLevel->shouldReceive('isPrimaryProperty')
            ->andReturnUsing(function ($propertyCode) use ($primaryPropertyCodes) {
                return in_array($propertyCode, $primaryPropertyCodes);
            });
        $professionLevel->shouldReceive('getProfession')
            ->andReturn($profession = $this->mockery(Profession::class));
        $profession->shouldReceive('getCode')
            ->andReturn('foo');

        return $professionLevel;
    }

    /**
     * @param $value
     * @return Strength<commit_msg>Fixed tests after incompatible change of a library<commit_after><?php
namespace DrdPlus\Exceptionalities;

use Drd\DiceRoll\RollInterface;
use DrdPlus\Exceptionalities\Fates\ExceptionalityFate;
use DrdPlus\Person\ProfessionLevels\ProfessionLevel;
use DrdPlus\Professions\Profession;
use DrdPlus\Properties\Base\Agility;
use DrdPlus\Properties\Base\BasePropertyFactory;
use DrdPlus\Properties\Base\Charisma;
use DrdPlus\Properties\Base\Intelligence;
use DrdPlus\Properties\Base\Knack;
use DrdPlus\Properties\Base\Strength;
use DrdPlus\Properties\Base\Will;
use DrdPlus\Tests\Tools\TestWithMockery;

class ExceptionalityPropertiesFactoryTest extends TestWithMockery
{
    /**
     * @param $strength
     * @param $agility
     * @param $knack
     * @param $will
     * @param $intelligence
     * @param $charisma
     *
     * @test
     * @dataProvider getChosenProperties
     */
    public function I_can_get_chosen_properties_tested_as_primary($strength, $agility, $knack, $will, $intelligence, $charisma)
    {
        $factory = new ExceptionalityPropertiesFactory();

        $chosenProperties = $factory->createChosenProperties(
            $this->createChosenFate(
                $strength + $agility + $knack + $will + $intelligence + $charisma,
                0,
                max($strength, $agility, $knack, $will, $intelligence, $charisma)
            ),
            $this->createProfessionLevel([
                Strength::STRENGTH,
                Agility::AGILITY,
                Knack::KNACK,
                Will::WILL,
                Intelligence::INTELLIGENCE,
                Charisma::CHARISMA,
            ]),
            $strength = $this->createStrength($strength),
            $agility = $this->createAgility($agility),
            $knack = $this->createKnack($knack),
            $will = $this->createWill($will),
            $intelligence = $this->createIntelligence($intelligence),
            $charisma = $this->createCharisma($charisma)
        );
        $this->assertSame($strength, $chosenProperties->getStrength());
        $this->assertSame($agility, $chosenProperties->getAgility());
        $this->assertSame($knack, $chosenProperties->getKnack());
        $this->assertSame($will, $chosenProperties->getWill());
        $this->assertSame($intelligence, $chosenProperties->getIntelligence());
        $this->assertSame($charisma, $chosenProperties->getCharisma());
    }

    public function getChosenProperties()
    {
        return [
            [1, 2, 3, 4, 5, 6],
        ];
    }

    /**
     * @param int $primaryPropertiesBonus
     * @param int $secondaryPropertiesBonus
     * @param int $upToSingleProperty
     * @return ExceptionalityFate
     */
    private function createChosenFate($primaryPropertiesBonus, $secondaryPropertiesBonus, $upToSingleProperty)
    {
        $fate = $this->mockery(ExceptionalityFate::class);
        $fate->shouldReceive('getSecondaryPropertiesBonusOnChoice')
            ->andReturn($secondaryPropertiesBonus);
        $fate->shouldReceive('getPrimaryPropertiesBonusOnChoice')
            ->andReturn($primaryPropertiesBonus);
        $fate->shouldReceive('getUpToSingleProperty')
            ->andReturn($upToSingleProperty);
        $fate->shouldReceive('getCode')
            ->andReturn('foo');

        return $fate;
    }

    /**
     * @param array $primaryPropertyCodes
     * @return ProfessionLevel
     */
    private function createProfessionLevel(array $primaryPropertyCodes)
    {
        $professionLevel = $this->mockery(ProfessionLevel::class);
        $professionLevel->shouldReceive('isPrimaryProperty')
            ->andReturnUsing(function ($propertyCode) use ($primaryPropertyCodes) {
                return in_array($propertyCode, $primaryPropertyCodes);
            });
        $professionLevel->shouldReceive('getProfession')
            ->andReturn($profession = $this->mockery(Profession::class));
        $profession->shouldReceive('getValue')
            ->andReturn('foo');

        return $professionLevel;
    }

    /**
     * @param $value
     * @return Strength
{'fraction_non_alphanumeric': 0.12281994595922378, 'fraction_numerical': 0.0017194792434291329, 'mean_word_length': 2.885019083969466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, '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': '7661301', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2258, 'n_words': 350}