<commit_before><?php
/**
 * Created by PhpStorm.
 * User: luckytianyiyan
 * Date: 16/12/16
 * Time: 上午1:55
 */

namespace Tests\Ty\DevMate;

use Ty\DevMate\Client;
use Ty\DevMate\CustomerModel;


class ClientTest extends \PHPUnit_Framework_TestCase
{
    const API_KEY = "<KEY>";
    
    private $email;
    
    public function __construct($name = null, array $data = array(), $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->email = time() . "@gmail.com";
    }

    public function testCreateCustomer()
    {
        $client = new Client(ClientTest::API_KEY);
        list($status, $customer) = $client->create_customer($this->email);
        $this->assertEquals(201, $status);
        $this->assertEquals($customer->email, $this->email);
        $this->assertEquals(0, count($customer->licenses));
        return $customer;
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testDuplicateCreateCustomer(CustomerModel $customer)
    {
        $this->setExpectedException(\Exception::class, '', 409);
        $client = new Client(ClientTest::API_KEY);
        $client->create_customer($customer->email);
    }

    /**
     * @depends testCreateCustomer
     */
    public function testFetchCustomers()
    {
        $client = new Client(ClientTest::API_KEY);
        list($status, $customers) = $client->fetch_customers();
        $this->assertEquals(200, $status);
        $this->assertGreaterThan(0, count($customers));
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testFetchSpecificCustomer(CustomerModel $customer)
    {
        $client = new Client(ClientTest::API_KEY);
        list($status, $fetched_customer) = $client->fetch_customer($customer->custom_id);
        $this->assertEquals(200, $status);
        $this->assertEquals($customer->custom_id, $fetched_customer->custom_id);
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testCreateLicense(CustomerModel $customer)
    {
        $client = new Client(ClientTest::API_KEY);
        $license_type_id = 1;
        list($status, $license) = $client->create_license($customer->custom_id, $license_type_id);
        $this->assertEquals(201, $status);
        $this->assertNotNull($license);
    }
}<commit_msg>M ClientTest<commit_after><?php
/**
 * Created by PhpStorm.
 * User: luckytianyiyan
 * Date: 16/12/16
 * Time: 上午1:55
 */

namespace Tests\Ty\DevMate;

use Ty\DevMate\Client;
use Ty\DevMate\CustomerModel;


class ClientTest extends \PHPUnit_Framework_TestCase
{
    const API_KEY = "<KEY>";
    
    private $email;
    private $client;
    
    public function __construct($name = null, array $data = array(), $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->email = time() . "@gmail.com";
        $this->client = new Client(ClientTest::API_KEY);
    }

    public function testCreateCustomer()
    {
        list($status, $customer) = $this->client->create_customer($this->email);
        $this->assertEquals(201, $status);
        $this->assertEquals($customer->email, $this->email);
        $this->assertEquals(0, count($customer->licenses));
        return $customer;
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testDuplicateCreateCustomer(CustomerModel $customer)
    {
        $this->setExpectedException(\Exception::class, '', 409);
        $this->client->create_customer($customer->email);
    }

    /**
     * @depends testCreateCustomer
     */
    public function testFetchCustomers()
    {
        list($status, $customers) = $this->client->fetch_customers();
        $this->assertEquals(200, $status);
        $this->assertGreaterThan(0, count($customers));
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testFetchSpecificCustomer(CustomerModel $customer)
    {
        list($status, $fetched_customer) = $this->client->fetch_customer($customer->custom_id);
        $this->assertEquals(200, $status);
        $this->assertEquals($customer->custom_id, $fetched_customer->custom_id);
    }

    /**
     * @param CustomerModel $customer created customer
     * @depends testCreateCustomer
     */
    public function testCreateLicense(CustomerModel $customer)
    {
        $license_type_id = 1;
        list($status, $license) = $this->client->create_license($customer->custom_id, $license_type_id);
        $this->assertEquals(201, $status);
        $this->assertNotNull($license);
    }
}
{'fraction_non_alphanumeric': 0.1419624217118998, 'fraction_numerical': 0.01127348643006263, 'mean_word_length': 3.115979381443299, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 61, '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': '728831', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1377, 'n_words': 255}