<commit_before><?php
namespace MangoPay\Tests;
require_once 'base.php';

/**
 * Tests basic CRUD methods for users
 */
class Users extends Base {

    function test_Users_CreateNatural() {
        $john = $this->getJohn();
        $this->assertTrue($john->Id > 0);
        $this->assertIdentical($john->PersonType, \MangoPay\PersonType::Natural);
    }

    function test_Users_CreateLegal() {
        $matrix = $this->getMatrix();
        $this->assertTrue($matrix->Id > 0);
        $this->assertIdentical($matrix->PersonType, \MangoPay\PersonType::Legal);
    }

    function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() {
        $user = new \MangoPay\UserLegal();
        $this->expectException();
        
        $ret = $this->_api->Users->Create($user);
        
        $this->fail("Creation should fail because required props are not set");
    }

    function test_Users_CreateLegal_PassesIfRequiredPropsProvided() {
        $user = new \MangoPay\UserLegal();
        $user->Name = "SomeOtherSampleOrg";
        $user->Email = "<EMAIL>";
        $user->LegalPersonType = "BUSINESS";
        $user->LegalRepresentativeFirstName = "FirstName";
        $user->LegalRepresentativeLastName = "LastName";
        $user->LegalRepresentativeAddress = "Address";
        $user->LegalRepresentativeBirthday = mktime(0, 0, 0, 12, 21, 1975);
        $user->LegalRepresentativeNationality = "FR";
        $user->LegalRepresentativeCountryOfResidence = "FR";

        $ret = $this->_api->Users->Create($user);

        $this->assertTrue($ret->Id > 0, "Created successfully after required props set");
        $this->assertIdenticalInputProps($user, $ret);
    }

    function tes_Users_GetNatural() {
        $john = $this->getJohn();

        $user1 = $this->_api->Users->Get($john->Id);
        $user2 = $this->_api->Users->GetNatural($john->Id);

        $this->assertIdentical($user1, $john);
        $this->assertIdentical($user2, $john);
        $this->assertIdenticalInputProps($user1, $john);
    }

    function test_Users_GetNatural_FailsForLegalUser() {
        $matrix = $this->getMatrix();
        $this->expectException();
        
        $user = $this->_api->Users->GetNatural($matrix->Id);<commit_msg>Rename wrong method name in test.<commit_after><?php
namespace MangoPay\Tests;
require_once 'base.php';

/**
 * Tests basic CRUD methods for users
 */
class Users extends Base {

    function test_Users_CreateNatural() {
        $john = $this->getJohn();
        $this->assertTrue($john->Id > 0);
        $this->assertIdentical($john->PersonType, \MangoPay\PersonType::Natural);
    }

    function test_Users_CreateLegal() {
        $matrix = $this->getMatrix();
        $this->assertTrue($matrix->Id > 0);
        $this->assertIdentical($matrix->PersonType, \MangoPay\PersonType::Legal);
    }

    function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() {
        $user = new \MangoPay\UserLegal();
        $this->expectException();
        
        $ret = $this->_api->Users->Create($user);
        
        $this->fail("Creation should fail because required props are not set");
    }

    function test_Users_CreateLegal_PassesIfRequiredPropsProvided() {
        $user = new \MangoPay\UserLegal();
        $user->Name = "SomeOtherSampleOrg";
        $user->Email = "<EMAIL>";
        $user->LegalPersonType = "BUSINESS";
        $user->LegalRepresentativeFirstName = "FirstName";
        $user->LegalRepresentativeLastName = "LastName";
        $user->LegalRepresentativeAddress = "Address";
        $user->LegalRepresentativeBirthday = mktime(0, 0, 0, 12, 21, 1975);
        $user->LegalRepresentativeNationality = "FR";
        $user->LegalRepresentativeCountryOfResidence = "FR";

        $ret = $this->_api->Users->Create($user);

        $this->assertTrue($ret->Id > 0, "Created successfully after required props set");
        $this->assertIdenticalInputProps($user, $ret);
    }

    function test_Users_GetNatural() {
        $john = $this->getJohn();

        $user1 = $this->_api->Users->Get($john->Id);
        $user2 = $this->_api->Users->GetNatural($john->Id);

        $this->assertIdentical($user1, $john);
        $this->assertIdentical($user2, $john);
        $this->assertIdenticalInputProps($user1, $john);
    }

    function test_Users_GetNatural_FailsForLegalUser() {
        $matrix = $this->getMatrix();
        $this->expectException();
        
        $user = $this->_api->Users->GetNatural($matrix->Id);
{'fraction_non_alphanumeric': 0.15448245025709814, 'fraction_numerical': 0.008495416946121171, 'mean_word_length': 3.0709736123748863, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 107, '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': '6162594', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1307, 'n_words': 222}