<commit_before><?php

namespace RestApiTest\Model;

use RestApi\Model\Customer;
use PHPUnit_Framework_TestCase;

class CustomerTest extends PHPUnit_Framework_TestCase
{
    /**
     * Used to automate tests by code reflection
     * @type {Array}
     */
    protected $fields = array('id', 'firstName', 'lastName', 'address', 'email');
    
    /**
     * A useful mock used to automate customer initialization
     * @type {Array}
     */
    protected $mockData = array(
        'id'     => 1,
        'firstName' => 'Jorge',
        'lastName'  => 'Albaladejo',
        'address'   => 'Rue de Lausanne, Renens, Switzerland',
        'email'     => '<EMAIL>'            
    );
    
    /**
     * Produces a mock customer with some predefined values (for DRY purposes)
     * @return {RestApi\Model\Customer}
     */
    protected function mockCustomer()
    {
        $customer = new Customer();        
        $customer->exchangeArray($this->mockData);        
        return $customer;
    }
    
    /*
     * Test cases
     */
    
    public function testCustomerInitialState()
    {
        $customer = new Customer();
        
        foreach ($this->fields as $field) 
        {
            $this->assertNull($customer->$field, '"' . $field . '" should initially be null');
        }
    }
    
    public function testExchangeArraySetsPropertiesCorrectly()
    {
        $customer = $this->mockCustomer();
        
        foreach ($this->fields as $field) 
        {
            $this->assertSame($this->mockData[$field], $customer->$field, '"' . $field . '" was not set correctly');
        }
    }
    
    public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent()
    {
        $customer = $this->mockCustomer();
        
        // now reset its values
        $customer->exchangeArray(array());
        
        foreach ($this->fields as $field) 
        {
            $this->assertNull($customer->$field, '"' . $field . '" should have defaulted to null');
        }
    }
    
    // @TODO
    public function testFirstNameValidates()
    {
      
    }
    
    public function testLastNameValidates()
    {
      
    }
    
    public function testAddressValidates()
    {
      
    }
    
    public function testEmailValidates()
    {
      
    }
}<commit_msg>completed unit tests for Customer<commit_after><?php

namespace RestApiTest\Model;

use RestApi\Model\Customer;
use PHPUnit_Framework_TestCase;

class CustomerTest extends PHPUnit_Framework_TestCase
{
    /**
     * Used to automate tests by code reflection
     * @type {Array}
     */
    protected $fields = array('id', 'firstName', 'lastName', 'address', 'email');
    
    /**
     * A useful mock used to automate customer initialization
     * @type {Array}
     */
    protected $mockData = array(
        'id'     => 1,
        'firstName' => 'Jorge',
        'lastName'  => 'Albaladejo',
        'address'   => 'Rue de Lausanne, Renens, Switzerland',
        'email'     => '<EMAIL>'            
    );
    
    /**
     * Produces a mock customer with some predefined values (for DRY purposes)
     * @return {RestApi\Model\Customer}
     */
    protected function mockCustomer()
    {
        $customer = new Customer();        
        $customer->exchangeArray($this->mockData);        
        return $customer;
    }
    
    /*
     * Test cases
     */
    
    public function testCustomerInitialState()
    {
        $customer = new Customer();
        
        foreach ($this->fields as $field) 
        {
            $this->assertNull($customer->$field, '"' . $field . '" should initially be null');
        }
    }
    
    public function testExchangeArraySetsPropertiesCorrectly()
    {
        $customer = $this->mockCustomer();
        
        foreach ($this->fields as $field) 
        {
            $this->assertSame($this->mockData[$field], $customer->$field, '"' . $field . '" was not set correctly');
        }
    }
    
    public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent()
    {
        $customer = $this->mockCustomer();
        
        // now reset its values
        $customer->exchangeArray(array());
        
        foreach ($this->fields as $field) 
        {
            $this->assertNull($customer->$field, '"' . $field . '" should have defaulted to null');
        }
    }
}
{'fraction_non_alphanumeric': 0.12660845588235295, 'fraction_numerical': 0.00045955882352941176, 'mean_word_length': 1.939230249831195, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, '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': '5932186', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1199, 'n_words': 279}