<commit_before><?php

use Beepsend\Client;
use Beepsend\Connector\Curl;

class UserTest extends PHPUnit_Framework_TestCase
{
    
    /**
     * Test getting user data
     */
    public function testGettingData()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me', 'GET', array())
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 200,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array(
                            'id' => 4,
                            'name' => 'Beep',
                            'customer' => 'Beepsend AB',
                            'api_token' => 'abc123'
                        ))
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->data();
        
        $this->assertInternalType('array', $user);
        $this->assertEquals(4, $user['id']);
        $this->assertEquals('Beep', $user['name']);
        $this->assertEquals('Beepsend AB', $user['customer']);
        $this->assertEquals('<PASSWORD>', $user['api_token']);
    }
    
    /**
     * Test updating some of user data
     */
    public function testUpdatingData()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me', 'PUT', array('name' => 'New Beepsend'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 200,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array(
                            'id' => 4,
                            'name' => 'New Beepsend',
                            'customer' => 'Beepsend AB',
                            'api_token' => 'abc123'
                        ))
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->update(array('name' => 'New Beepsend'));
        
        $this->assertInternalType('array', $user);
        $this->assertEquals(4, $user['id']);
        $this->assertEquals('New Beepsend', $user['name']);
        $this->assertEquals('Beepsend AB', $user['customer']);
        $this->assertEquals('abc123', $user['api_token']);
    }
    
    /**
     * Test updating user email address
     */
    public function testUpdatingUserEmail()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me/email', 
                            'PUT', 
                            array('email' => '<EMAIL>', 'password' => '<PASSWORD>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->updateEmail('<EMAIL>', '<PASSWORD>');
        
        $this->assertInternalType('array', $user);
    }
    
    /**
     * Test updating user password
     */
    public function testUpdatingUserPassword()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me/password', 
                            'PUT', 
                            array('password' => '<PASSWORD>', 'new_password' => '<PASSWORD>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->updatePassword('<PASSWORD>', '<PASSWORD>');
        
        $this->assertInternalType('array', $user);
    }
    
    /**
     * Test reseting user password
     */
    public function testResetingUserPassword()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/passwordreset', 
                            'GET', 
                            array('email' => '<EMAIL>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->resetUserPassword('<EMAIL>');
        
        $this->assertInternalType('array', $user);
    }
    
}<commit_msg>Created test for setting new user password via reset hash<commit_after><?php

use Beepsend\Client;
use Beepsend\Connector\Curl;

class UserTest extends PHPUnit_Framework_TestCase
{
    
    /**
     * Test getting user data
     */
    public function testGettingData()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me', 'GET', array())
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 200,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array(
                            'id' => 4,
                            'name' => 'Beep',
                            'customer' => 'Beepsend AB',
                            'api_token' => 'abc123'
                        ))
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->data();
        
        $this->assertInternalType('array', $user);
        $this->assertEquals(4, $user['id']);
        $this->assertEquals('Beep', $user['name']);
        $this->assertEquals('Beepsend AB', $user['customer']);
        $this->assertEquals('abc123', $user['api_token']);
    }
    
    /**
     * Test updating some of user data
     */
    public function testUpdatingData()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me', 'PUT', array('name' => 'New Beepsend'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 200,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array(
                            'id' => 4,
                            'name' => 'New Beepsend',
                            'customer' => 'Beepsend AB',
                            'api_token' => 'abc<PASSWORD>'
                        ))
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->update(array('name' => 'New Beepsend'));
        
        $this->assertInternalType('array', $user);
        $this->assertEquals(4, $user['id']);
        $this->assertEquals('New Beepsend', $user['name']);
        $this->assertEquals('Beepsend AB', $user['customer']);
        $this->assertEquals('abc123', $user['api_token']);
    }
    
    /**
     * Test updating user email address
     */
    public function testUpdatingUserEmail()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me/email', 
                            'PUT', 
                            array('email' => '<EMAIL>', 'password' => '<PASSWORD>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->updateEmail('<EMAIL>', '<PASSWORD>');
        
        $this->assertInternalType('array', $user);
    }
    
    /**
     * Test updating user password
     */
    public function testUpdatingUserPassword()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/me/password', 
                            'PUT', 
                            array('password' => '<PASSWORD>', 'new_password' => '<PASSWORD>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->updatePassword('<PASSWORD>', '<PASSWORD>');
        
        $this->assertInternalType('array', $user);
    }
    
    /**
     * Test reseting user password
     */
    public function testResetingUserPassword()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/passwordreset', 
                            'GET', 
                            array('email' => '<EMAIL>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array())
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->resetUserPassword('<EMAIL>');
        
        $this->assertInternalType('array', $user);
    }
    
    /**
     * Test setting new password with reset hash
     */
    public function testSettingNewPassword()
    {
        $connector = \Mockery::mock(new Curl());
        $connector->shouldReceive('call')
                    ->with('https://api.beepsend.com/2/users/password/abchash', 
                            'PUT', 
                            array('password' => '<PASSWORD>'))
                    ->once()
                    ->andReturn(array(
                        'info' => array(
                            'http_code' => 204,
                            'Content-Type' => 'application/json'
                        ),
                        'response' => json_encode(array(
                            'id' => 4,
                            'name' => 'Beep',
                            'customer' => 'Beepsend AB',
                            'api_token' => '<PASSWORD>'
                        ))
                    ));
        
        $client = new Client('abc123', $connector);
        $user = $client->user->setNewPassword('<PASSWORD>', '<PASSWORD>');
        
        $this->assertInternalType('array', $user);
        $this->assertEquals(4, $user['id']);
        $this->assertEquals('Beep', $user['name']);
        $this->assertEquals('Beepsend AB', $user['customer']);
        $this->assertEquals('abc<PASSWORD>', $user['api_token']);
    }
    
}
{'fraction_non_alphanumeric': 0.15315315315315314, 'fraction_numerical': 0.0085995085995086, 'mean_word_length': 1.2307270734380709, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 206, 'https://': 11, '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': '2616779', 'n_tokens_mistral': 3197, 'n_tokens_neox': 3040, 'n_words': 510}