<commit_before><?php

namespace TijsVerkoyen\Bpost\tests;

require_once __DIR__ . '/../../../autoload.php';
require_once 'config.php';

use \TijsVerkoyen\Bpost\Bpost;

/**
 * test case.
 */
class BpostTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Bpost
     */
    private $bpost;

    /**
     * Prepares the environment before running a test.
     */
    protected function setUp()
    {
        parent::setUp();
        $this->bpost = new Bpost(ACCOUNT_ID, PASSPHRASE);
    }

    /**
     * Cleans up the environment after running a test.
     */
    protected function tearDown()
    {
        $this->bpost = null;
        parent::tearDown();
    }

    /**
     * Tests Bpost->getTimeOut()
     */
    public function testGetTimeOut()
    {
        $this->bpost->setTimeOut(5);
        $this->assertEquals(5, $this->bpost->getTimeOut());
    }

    /**
     * Tests Bpost->getUserAgent()
     */
    public function testGetUserAgent()
    {
        $this->bpost->setUserAgent('testing/1.0.0');
        $this->assertEquals('PHP Bpost/' . Bpost::VERSION . ' testing/1.0.0', $this->bpost->getUserAgent());
    }
}<commit_msg>Implemented a test for creating an order<commit_after><?php

namespace TijsVerkoyen\Bpost\tests;

require_once __DIR__ . '/../../../autoload.php';
require_once 'config.php';

use \TijsVerkoyen\Bpost\Bpost;
use \TijsVerkoyen\Bpost\Bpost\Order;
use \TijsVerkoyen\Bpost\Bpost\Order\Address;
use \TijsVerkoyen\Bpost\Bpost\Order\Box;
use \TijsVerkoyen\Bpost\Bpost\Order\Box\AtHome;
use \TijsVerkoyen\Bpost\Bpost\Order\Box\Option\Messaging;
use \TijsVerkoyen\Bpost\Bpost\Order\Line as OrderLine;
use \TijsVerkoyen\Bpost\Bpost\Order\Receiver;
use \TijsVerkoyen\Bpost\Bpost\Order\Sender;

/**
 * test case.
 */
class BpostTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Bpost
     */
    private $bpost;

    /**
     * Prepares the environment before running a test.
     */
    protected function setUp()
    {
        parent::setUp();
        $this->bpost = new Bpost(ACCOUNT_ID, PASSPHRASE);
    }

    /**
     * Cleans up the environment after running a test.
     */
    protected function tearDown()
    {
        $this->bpost = null;
        parent::tearDown();
    }

    /**
     * Tests Bpost->getTimeOut()
     */
    public function testGetTimeOut()
    {
        $this->bpost->setTimeOut(5);
        $this->assertEquals(5, $this->bpost->getTimeOut());
    }

    /**
     * Tests Bpost->getUserAgent()
     */
    public function testGetUserAgent()
    {
        $this->bpost->setUserAgent('testing/1.0.0');
        $this->assertEquals('PHP Bpost/' . Bpost::VERSION . ' testing/1.0.0', $this->bpost->getUserAgent());
    }

    /**
     * Tests Bpost->createOrReplaceOrder
     */
    public function testCreateOrReplaceOrder()
    {
        // create order
        $orderId = time();
        $order = new Order($orderId);
        $order->setCostCenter('Cost Center');

        // add lines
        $line1 = new OrderLine('Beer', 1);
        $order->addLine($line1);
        $line2 = new OrderLine('Whisky', 100);
        $order->addLine($line2);

        // add box
        $address = new Address();
        $address->setStreetName('Afrikalaan');
        $address->setNumber('289');
        $address->setPostalCode('9000');
        $address->setLocality('Gent');
        $address->setCountryCode('BE');

        $sender = new Sender();
        $sender->setAddress($address);
        $sender->setName('<NAME>');
        $sender->setCompany('Sumo Coders');
        $sender->setPhoneNumber('+32 9 395 02 51');
        $sender->setEmailAddress('<EMAIL>');

        $box = new Box();
        $box->setSender($sender);
        $box->setRemark('Remark');

        // add label
        $address = new Address();
        $address->setStreetName('Kerkstraat');
        $address->setNumber('108');
        $address->setPostalCode('9050');
        $address->setLocality('Gentbrugge');
        $address->setCountryCode('BE');

        $receiver = new Receiver();
        $receiver->setAddress($address);
        $receiver->setName('<NAME>');
        $receiver->setCompany('Sumo Coders');
        $receiver->setPhoneNumber('+32 9 395 02 51');
        $receiver->setEmailAddress('<EMAIL>');

        // options
        $option = new Messaging('infoDistributed', 'NL', '<EMAIL>');

        // @Home
        $atHome = new AtHome();
        $atHome->setProduct('bpack 24h Pro');
        $atHome->setWeight(2000);
        $atHome->setReceiver($receiver);
        $atHome->addOption($option);
        $box->setNationalBox($atHome);

        $order->addBox($box);

        $response = $this->bpost->createOrReplaceOrder($order);
        $this->assertTrue($response);
    }
}
{'fraction_non_alphanumeric': 0.16521923321330226, 'fraction_numerical': 0.013556449904681212, 'mean_word_length': 2.4167872648335744, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 71, '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': '7349545', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1540, 'n_words': 258}