<commit_before><?php
/**
 * Definition of ActivateServiceTest
 *
 * @copyright  2015-today Justso GmbH
 * @author     <EMAIL>
 */

namespace justso\justauth;

use justso\justapi\Bootstrap;
use justso\justapi\NotFoundException;
use justso\justapi\testutil\ServiceTestBase;

/**
 * Class ActivateServiceTest
 */
class ActivateServiceTest extends ServiceTestBase
{
    public function testActivation()
    {
        $conf = ['environments' => ['test' => [
            'approot' => '/approot',
            'appurl' => 'http://example.com'
        ]]];
        Bootstrap::getInstance()->setTestConfiguration('/approot', $conf);
        $env = $this->createTestEnvironment(['c' => '12345']);
        $auth = $this->getMock('\justso\justauth\Authenticator', [], [], '', false);
        $auth->expects($this->once())->method('activate')->with('12345')->willReturn('dest');
        $env->setDICEntry('Authenticator', $auth);
        $service = new Activate($env);
        $service->getAction();
        $this->assertTrue(in_array('Location: http://example.com/dest', $env->getResponseHeader()));
    }

    /**
     * @expectedException \justso\justapi\InvalidParameterException
     */
    public function testWithoutActivationCode()
    {
        $env = $this->createTestEnvironment();
        $service = new Activate($env);
        $service->getAction();
    }

    /**
     * @expectedException \justso\justapi\DenyException
     */
    public function testWrongActivationCode()
    {
        $env = $this->createTestEnvironment(['c' => '12345']);
        $auth = $this->getMock('\justso\justauth\Authenticator', [], [], '', false);
        $auth->expects($this->once())->method('activate')->with('12345')->willThrowException(new NotFoundException());
        $env->setDICEntry('Authenticator', $auth);
        $service = new Activate($env);
        $service->getAction();
    }
}<commit_msg>Code coverage analysis: Ignore end of test functions which are expected to throw exceptions<commit_after><?php
/**
 * Definition of ActivateServiceTest
 *
 * @copyright  2015-today Justso GmbH
 * @author     <EMAIL>
 */

namespace justso\justauth;

use justso\justapi\Bootstrap;
use justso\justapi\NotFoundException;
use justso\justapi\testutil\ServiceTestBase;

/**
 * Class ActivateServiceTest
 */
class ActivateServiceTest extends ServiceTestBase
{
    public function testActivation()
    {
        $conf = ['environments' => ['test' => [
            'approot' => '/approot',
            'appurl' => 'http://example.com'
        ]]];
        Bootstrap::getInstance()->setTestConfiguration('/approot', $conf);
        $env = $this->createTestEnvironment(['c' => '12345']);
        $auth = $this->getMock('\justso\justauth\Authenticator', [], [], '', false);
        $auth->expects($this->once())->method('activate')->with('12345')->willReturn('dest');
        $env->setDICEntry('Authenticator', $auth);
        $service = new Activate($env);
        $service->getAction();
        $this->assertTrue(in_array('Location: http://example.com/dest', $env->getResponseHeader()));
    }

    /**
     * @expectedException \justso\justapi\InvalidParameterException
     */
    public function testWithoutActivationCode()
    {
        $env = $this->createTestEnvironment();
        $service = new Activate($env);
        $service->getAction();
        // @codeCoverageIgnoreStart
    }
    // @codeCoverageIgnoreEnd

    /**
     * @expectedException \justso\justapi\DenyException
     */
    public function testWrongActivationCode()
    {
        $env = $this->createTestEnvironment(['c' => '12345']);
        $auth = $this->getMock('\justso\justauth\Authenticator', [], [], '', false);
        $auth->expects($this->once())->method('activate')->with('12345')->willThrowException(new NotFoundException());
        $env->setDICEntry('Authenticator', $auth);
        $service = new Activate($env);
        $service->getAction();
        // @codeCoverageIgnoreStart
    }
    // @codeCoverageIgnoreEnd
}
{'fraction_non_alphanumeric': 0.17494979919678716, 'fraction_numerical': 0.012048192771084338, 'mean_word_length': 3.2213983050847457, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 63, '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': '6682321', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1144, 'n_words': 181}