<commit_before><?php
App::uses('ProgramSettingsController', 'Controller');

class TestProgramSettingsController extends ProgramSettingsController
{
/**
 * Auto render
 *
 * @var boolean
 */
    public $autoRender = false;

/**
 * Redirect action
 *
 * @param mixed $url
 * @param mixed $status
 * @param boolean $exit
 * @return void
 */
    public function redirect($url, $status = null, $exit = true) {
        $this->redirectUrl = $url;
    }


}


class ProgramSettingsControllerTestCase extends ControllerTestCase 
{
    /**
    * Data
    *
    */

    var $programData = array(
        0 => array( 
            'Program' => array(
            'name' => '<NAME>',
            'url' => 'testurl',
            'timezone' => 'utc',
            'database' => 'testdbprogram'
        )
     ));


    public function setUp()
    {
        parent::setUp();
        $this->ProgramSettings = new TestProgramSettingsController();
        $this->dropData();
    }


    protected function dropData()
    {
        $this->instanciateProgramSettingsModel();
        $this->ProgramSettings->ProgramSetting->deleteAll(true, false);
    }


    protected function instanciateProgramSettingsModel() 
    {
        $options = array('database' => $this->programData[0]['Program']['database']);
        $this->ProgramSettings->ProgramSetting = new ProgramSetting($options);
    }
    

    public function tearDown()
    {
        $this->dropData();
        unset($this->ProgramSettings);
        parent::tearDown();
    }


    protected function mockProgramAccess()
    {
        $ProgramSettings = $this->generate('ProgramSettings', array(
            'components' => array(
                'Acl' => array('check'),
                'Session' => array('read')
            ),
            'models' => array(
                'Program' => array('find', 'count'),
                'Group' => array()
             )
         ));
        
        $ProgramSettings->Acl
            ->expects($this->any())
            ->method('check')
            ->will($this->returnValue('true'));
            
        $ProgramSettings->Program
            ->expects($this->once())
            ->method('find')
            ->will($this->returnValue($this->programData));

        $ProgramSettings->Session
            ->expects($this->any())
            ->method('read')
            ->will($this->onConsecutiveCalls(
                '4', 
                '2',
                $this->programData[0]['Program']['database'],
                $this->programData[0]['Program']['name']
                )); 
    }


/**
 * Test Methods
 */
    public function testEdit() 
    {
        $this->mockProgramAccess();

        $programSettings = array(
            'ProgramSettings' => array(
                'shortcode'=>'8282',
                'timezone'=> 'EAT'
                )
            );
            
        $this->testAction("/testurl/programSettings/edit", array(
            'method' => 'post',
            'data' => $programSettings<commit_msg>fixed program settings test case to include international prefix<commit_after><?php
App::uses('ProgramSettingsController', 'Controller');

class TestProgramSettingsController extends ProgramSettingsController
{
/**
 * Auto render
 *
 * @var boolean
 */
    public $autoRender = false;

/**
 * Redirect action
 *
 * @param mixed $url
 * @param mixed $status
 * @param boolean $exit
 * @return void
 */
    public function redirect($url, $status = null, $exit = true) {
        $this->redirectUrl = $url;
    }


}


class ProgramSettingsControllerTestCase extends ControllerTestCase 
{
    /**
    * Data
    *
    */

    var $programData = array(
        0 => array( 
            'Program' => array(
            'name' => '<NAME>',
            'url' => 'testurl',
            'timezone' => 'utc',
            'database' => 'testdbprogram'
        )
     ));


    public function setUp()
    {
        parent::setUp();
        $this->ProgramSettings = new TestProgramSettingsController();
        $this->dropData();
    }


    protected function dropData()
    {
        $this->instanciateProgramSettingsModel();
        $this->ProgramSettings->ProgramSetting->deleteAll(true, false);
    }


    protected function instanciateProgramSettingsModel() 
    {
        $options = array('database' => $this->programData[0]['Program']['database']);
        $this->ProgramSettings->ProgramSetting = new ProgramSetting($options);
    }
    

    public function tearDown()
    {
        $this->dropData();
        unset($this->ProgramSettings);
        parent::tearDown();
    }


    protected function mockProgramAccess()
    {
        $ProgramSettings = $this->generate('ProgramSettings', array(
            'components' => array(
                'Acl' => array('check'),
                'Session' => array('read')
            ),
            'models' => array(
                'Program' => array('find', 'count'),
                'Group' => array()
             )
         ));
        
        $ProgramSettings->Acl
            ->expects($this->any())
            ->method('check')
            ->will($this->returnValue('true'));
            
        $ProgramSettings->Program
            ->expects($this->once())
            ->method('find')
            ->will($this->returnValue($this->programData));

        $ProgramSettings->Session
            ->expects($this->any())
            ->method('read')
            ->will($this->onConsecutiveCalls(
                '4', 
                '2',
                $this->programData[0]['Program']['database'],
                $this->programData[0]['Program']['name']
                )); 
    }


/**
 * Test Methods
 */
    public function testEdit() 
    {
        $this->mockProgramAccess();

        $programSettings = array(
            'ProgramSettings' => array(
                'shortcode'=>'8282',
                'internationalprefix'=>'256',
                'timezone'=> 'EAT'
                )
            );
            
        $this->testAction("/testurl/programSettings/edit", array(
            'method' => 'post',
            'data' => $programSettings
{'fraction_non_alphanumeric': 0.15302956067287277, 'fraction_numerical': 0.0037563285970929282, 'mean_word_length': 1.8404452690166977, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 114, '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': '4737625', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1577, 'n_words': 286}