<commit_before><?php

namespace Cpeter\PhpQkeylmEmailNotification\Test\Qkeylm;

use Mockery as m;
use Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi;
use Cpeter\PhpQkeylmEmailNotification\Test\TestCase;

class QkeylmTest extends TestCase
{

//$mock = M::mock('Engineering');
//$mock->shouldReceive('disengageWarp')->once()->ordered();
//$mock->shouldReceive('divertPower')->with(0.40, 'sensors')->once()->ordered();
//$mock->shouldReceive('divertPower')->with(0.30, 'auxengines')->once()->ordered();
//$mock->shouldReceive('runDiagnosticLevel')->with(1)->once()->ordered();
    
    /**
     * Check config object
     * @covers Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi::__construct
     */
    public function testConfigObjAfterInit()
    {
        $qkeylm_api = new QkeylmApi(['host' => 'http://www.host.org']);
        
        // check private property
        $property = $this->getPrivateProperty( 'Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi', 'config' );
        $config = $property->getValue( $qkeylm_api );
    
        $this->assertTrue(is_array($config) && !empty($config));
        $this->assertTrue($config['host'] == 'http://www.host.org');
    }

    /**
     * Check default value works
     * @covers Cpeter\PhpQkeylmEmailNotification\Configuration\Configuration::get
     */
    public function testGet()
    {
//        $configuration = Configuration::defaults();
//        $config = $configuration->get('invalid', 'default');
//        $this->assertTrue($config == 'default');
    }

    /**
     * getPrivateProperty
     *
     * @param 	string $className
     * @param 	string $propertyName
     * @return	ReflectionProperty
     */
    public function getPrivateProperty( $className, $propertyName ) {
        $reflector = new \ReflectionClass( $className );
        $property = $reflector->getProperty( $propertyName );
        $property->setAccessible( true );

        return $property;
    }
}<commit_msg>mock something<commit_after><?php

namespace Cpeter\PhpQkeylmEmailNotification\Test\Qkeylm;

use Mockery as m;
use Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi;
use Cpeter\PhpQkeylmEmailNotification\Test\TestCase;

class QkeylmTest extends TestCase
{

//$mock = M::mock('Engineering');
//$mock->shouldReceive('disengageWarp')->once()->ordered();
//$mock->shouldReceive('divertPower')->with(0.40, 'sensors')->once()->ordered();
//$mock->shouldReceive('divertPower')->with(0.30, 'auxengines')->once()->ordered();
//$mock->shouldReceive('runDiagnosticLevel')->with(1)->once()->ordered();
    
    /**
     * Check config object
     * 
     * Get a private property
     * 
     * @covers Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi::__construct
     */
    public function testConfigObjAfterInit()
    {
        $qkeylm_api = new QkeylmApi(['host' => 'http://www.host.org']);
        
        // check private property
        $property = $this->getPrivateProperty( 'Cpeter\PhpQkeylmEmailNotification\Qkeylm\QkeylmApi', 'config' );
        $config = $property->getValue( $qkeylm_api );
    
        $this->assertTrue(is_array($config) && !empty($config));
        $this->assertTrue($config['host'] == 'http://www.host.org');
    }

    /**
     * Check default value works
     * 
     * Mock a method
     * 
     * @covers Cpeter\PhpQkeylmEmailNotification\Configuration\Configuration::get
     */
    public function testGetDailyJournal()
    {
        $mock = M::mock('QkeylmApi');
        $mock->
    }

    /**
     * Check authToken extraction
     * 
     * @covers Cpeter\PhpQkeylmEmailNotification\Configuration\Configuration::getAuthToken
     */
    public function testGetAuthToken()
    {
        $qkeylm_api = new QkeylmApi(['host' => 'http://www.host.org']);
        $token = $this->invokeMethod($qkeylm_api, 'getAuthToken', ['name="__RequestVerificationToken" type="hidden" value="<PASSWORD>"']);
        $this->assertTrue($token == '<PASSWORD>');
    }
    
    /**
     * getPrivateProperty
     *
     * @param 	string $className
     * @param 	string $propertyName
     * @return	ReflectionProperty
     */
    public function getPrivateProperty( $className, $propertyName ) {
        $reflector = new \ReflectionClass( $className );
        $property = $reflector->getProperty( $propertyName );
        $property->setAccessible( true );

        return $property;
    }

    /**
     * Call protected/private method of a class.
     *
     * @param object &$object    Instantiated object that we will run method on.
     * @param string $methodName Method name to call
     * @param array  $parameters Array of parameters to pass into method.
     *
     * @return mixed Method return.
     */
    public function invokeMethod(&$object, $methodName, array $parameters = array())
    {
        $reflection = new \ReflectionClass(get_class($object));
        $method = $reflection->getMethod($methodName);
        $method->setAccessible(true);

        return $method->invokeArgs($object, $parameters);
    }

    public function tearDown()
    {
        M::close();
    }
    
}
{'fraction_non_alphanumeric': 0.1536031589338598, 'fraction_numerical': 0.002764067127344521, 'mean_word_length': 3.128769356153219, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, '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': '4039173', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1543, 'n_words': 262}