<commit_before><?php
/**
 * This file is part of the ProxmoxVE PHP API wrapper library (unofficial).
 *
 * @copyright 2014 <NAME> <<EMAIL>>
 * @license http://opensource.org/licenses/MIT The MIT License.
 */

namespace ProxmoxVE;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProxmoxTest extends \PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $fakeToken = new AuthToken('csrf', 'ticket', 'owner');

        $this->credentials = $this->getMockBuilder('ProxmoxVE\Credentials')
                                  ->setMethods(array('login'))
                                  ->setConstructorArgs(array('myproxmox.tld', 'root', 'abc123'))
                                  ->getMock();

        $this->credentials->expects($this->any())
            ->method('login')
            ->will($this->returnValue($fakeToken));

        $this->proxmox = new Proxmox($this->credentials);
    }


    public function testGetCredentials()
    {
        $this->assertSame($this->credentials, $this->proxmox->getCredentials());
    }


    public function testSetCredentials()
    {
        $fakeToken = new AuthToken('csrf', 'ticket', 'owner');

        $newCredentials = $this->getMockBuilder('ProxmoxVE\Credentials')
                               ->setMethods(array('login'))
                               ->setConstructorArgs(array('host', 'user', 'pass'))
                               ->getMock();

        $newCredentials->expects($this->any())
                       ->method('login')
                       ->will($this->returnValue($fakeToken));

        $this->proxmox->setCredentials($newCredentials);

        $this->assertEquals($newCredentials, $this->proxmox->getCredentials());
    }


    /**
     * @expectedException \InvalidArgumentException
     */
    public function testConstructorThrowsExceptionWhenBadParamsArePassed()
    {
        $data = array('hostname', 'password', 'username', 'port', 'realm');
        $proxmoxApi = new Proxmox($data);
    }

}<commit_msg>Tests refactored<commit_after><?php
/**
 * This file is part of the ProxmoxVE PHP API wrapper library (unofficial).
 *
 * @copyright 2014 <NAME> <<EMAIL>>
 * @license http://opensource.org/licenses/MIT The MIT License.
 */

namespace ProxmoxVE;

/**
 * @author <NAME> <<EMAIL>>
 */
class ProxmoxTest extends \PHPUnit_Framework_TestCase
{
    public function getMockCredentials($constructArgs = array())
    {
        $mockCredentials = $this->getMockBuilder('ProxmoxVE\Credentials')
                                ->setMethods(array('login'))
                                ->setConstructorArgs($constructArgs)
                                ->getMock();

        $fakeToken = new AuthToken('csrf', 'ticket', 'owner');

        $mockCredentials->expects($this->any())
                        ->method('login')
                        ->will($this->returnValue($fakeToken));

        return $mockCredentials;
    }


    public function testGetAndSetCredentials()
    {
        $credentials = $this->getMockCredentials(array('my.proxmox.tld', 'root', '123abc'));
        $proxmox = new Proxmox($credentials);
        $this->assertSame($credentials, $proxmox->getCredentials());

        $newCredentials = $this->getMockCredentials(array('host', 'user', 'pass'));
        $proxmox->setCredentials($newCredentials);
        $this->assertEquals($newCredentials, $proxmox->getCredentials());
    }


    /**
     * @expectedException \InvalidArgumentException
     */
    public function testConstructorThrowsExceptionWhenBadParamsArePassed()
    {
        $data = array('hostname', 'password', 'username', 'port', 'realm');
        $proxmoxApi = new Proxmox($data);
    }

}
{'fraction_non_alphanumeric': 0.15068119891008175, 'fraction_numerical': 0.0038147138964577656, 'mean_word_length': 2.4340505144995324, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5592537', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1027, 'n_words': 176}