<commit_before><?php

/**
 * @loadSharedFixture
 */
class SPM_ShopyMind_Test_Lib_ShopymindClient_Callback_GetBirthdayClientsSignup extends EcomDev_PHPUnit_Test_Case
{
    public function testGetBirthdayClientsSignupShoulReturnEmptyIfNoCustomersMatchFilters() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2015-10-21 12:34:56', array());
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $this->assertEmpty($resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientWhichCreateTheirAccountAtDateReference() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array());
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $expected = array('1', '3', '4');
        $this->assertEquals($expected, $resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectCountry() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array(array('country' => 'US')));
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $expected = array('3', '4');
        $this->assertEquals($expected, $resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectCountryAndRegion() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array(array('country' => 'US', 'region' => 'AL')));
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $expected = array('3');
        $this->assertEquals($expected, $resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectRegion() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array(array('region' => 'AL')));
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $expected = array('3');
        $this->assertEquals($expected, $resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectRegionsAndCountries() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array(array('country' => 'US', 'region' => 'AL'), array('country' => 'FR')));
        $resultCustomerIds = array_map(function($customer) { return $customer['customer']['id_customer']; }, $results);

        $expected = array('3');
        $this->assertEquals($expected, $resultCustomerIds);
    }

    public function testGetBirthdayClientsSignupShoulReturnClientCountCorrespondingToFilters() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(1, '2014-10-21 12:34:56', array(), true);

        $expected = 3;
        $this->assertEquals($expected, $results['count']);
    }

}<commit_msg>Extract method / use new store notation -refs #16<commit_after><?php

/**
 * @loadSharedFixture
 */
class SPM_ShopyMind_Test_Lib_ShopymindClient_Callback_GetBirthdayClientsSignup extends EcomDev_PHPUnit_Test_Case
{
    public function testGetBirthdayClientsSignupShoulReturnEmptyIfNoCustomersMatchFilters() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2015-10-21 12:34:56', array());

        $this->assertEmpty($this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientWhichCreateTheirAccountAtDateReference() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array());

        $expected = array('1', '3', '4');
        $this->assertEquals($expected, $this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectCountry() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array(array('country' => 'US')));

        $expected = array('3', '4');
        $this->assertEquals($expected, $this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectCountryAndRegion() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array(array('country' => 'US', 'region' => 'AL')));

        $expected = array('3');
        $this->assertEquals($expected, $this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectRegion() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array(array('region' => 'AL')));

        $expected = array('3');
        $this->assertEquals($expected, $this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientInCorrectRegionsAndCountries() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array(array('country' => 'US', 'region' => 'AL'), array('country' => 'FR')));

        $expected = array('3');
        $this->assertEquals($expected, $this->extractCustomerIds($results));
    }

    public function testGetBirthdayClientsSignupShoulReturnClientCountCorrespondingToFilters() {
        $results = ShopymindClient_Callback::getBirthdayClientsSignUp(false, '2014-10-21 12:34:56', array(), true);

        $expected = 3;
        $this->assertEquals($expected, $results['count']);
    }

    private function extractCustomerIds($customers) {
        return array_map(function($customer) { return $customer['customer']['id_customer']; }, $customers);
    }
}
{'fraction_non_alphanumeric': 0.1444141689373297, 'fraction_numerical': 0.03797683923705722, 'mean_word_length': 5.30827067669173, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '5330542', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1723, 'n_words': 247}