<commit_before><?php
/**
 * Desire2Learn Web Serivces for Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.
 * It is also available through the world-wide-web at this URL:
 * https://github.com/adamlundrigan/zfD2L/blob/master/LICENSE
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 * 
 * @copyright  Copyright (c) 2011 Centre for Distance Learning and Innovation
 * @license    New BSD License 
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */

/**
 * PHPUnit live-server test for D2LWS_OrgUnit_Department_API
 * @author <NAME> <<EMAIL>>
 * 
 * @group D2LWS
 * @group D2LWS_API
 * @group D2LWS_OrgUnit
 * @group D2LWS_OrgUnit_Department
 * @group D2LWS_Live
 */
class D2LWS_OrgUnit_Department_APILiveTest extends LiveTestCase
{

    /**
     * Service API
     * @var D2LWS_OrgUnit_Department_API
     */
    protected $service = NULL;
    
    /**
     * Set up the Service API instance
     */
    public function setUp()
    {
        parent::setUp();
        
        $api = $this->_getInstanceManager();
        $this->service = new D2LWS_OrgUnit_Department_API($api);
    }
    
    /**
     * Fetch our test department by it's ID
     */
    public function testFindByIdentifierWhichExists()
    {
        $ouid = $this->config->phpunit->live->department->ouid;
        
        $objDepartment = $this->service->findByID($ouid);
        $this->assertInstanceOf('D2LWS_OrgUnit_Department_Model', $objDepartment);        
        $this->assertEquals($ouid, $objDepartment->getID());
        
        return $objDepartment;
    }
    
    /**
     * Attempt to fetch a non-existent OUID
     * @expectedException D2LWS_OrgUnit_Department_Exception_NotFound
     */
    public function testFindByIdentifierWhichDoesNotExist()
    {
        $ouid = '999999999';
        $objDepartment = $this->service->findByID($ouid);
    }
    
}<commit_msg>[feature/create] Implemented live test for D2LWS_OrgUnit_Department_API::findByCode<commit_after><?php
/**
 * Desire2Learn Web Serivces for Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.
 * It is also available through the world-wide-web at this URL:
 * https://github.com/adamlundrigan/zfD2L/blob/master/LICENSE
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to <EMAIL> so we can send you a copy immediately.
 * 
 * @copyright  Copyright (c) 2011 Centre for Distance Learning and Innovation
 * @license    New BSD License 
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 */

/**
 * PHPUnit live-server test for D2LWS_OrgUnit_Department_API
 * @author <NAME> <<EMAIL>>
 * 
 * @group D2LWS
 * @group D2LWS_API
 * @group D2LWS_OrgUnit
 * @group D2LWS_OrgUnit_Department
 * @group D2LWS_Live
 */
class D2LWS_OrgUnit_Department_APILiveTest extends LiveTestCase
{

    /**
     * Service API
     * @var D2LWS_OrgUnit_Department_API
     */
    protected $service = NULL;
    
    /**
     * Set up the Service API instance
     */
    public function setUp()
    {
        parent::setUp();
        
        $api = $this->_getInstanceManager();
        $this->service = new D2LWS_OrgUnit_Department_API($api);
    }
    
    /**
     * Fetch our test department by it's ID
     */
    public function testFindByIdentifierWhichExists()
    {
        $ouid = $this->config->phpunit->live->department->ouid;
        
        $objDepartment = $this->service->findByID($ouid);
        $this->assertInstanceOf('D2LWS_OrgUnit_Department_Model', $objDepartment);        
        $this->assertEquals($ouid, $objDepartment->getID());
        
        return $objDepartment;
    }
    
    /**
     * Attempt to fetch a non-existent OUID
     * @expectedException D2LWS_OrgUnit_Department_Exception_NotFound
     */
    public function testFindByIdentifierWhichDoesNotExist()
    {
        $ouid = '999999999';
        $objDepartment = $this->service->findByID($ouid);
    }
    
    /**
     * Fetch our test course template by it's code
     * @depends testFindByIdentifierWhichExists
     */
    public function testFindByCodeWhichExists(D2LWS_OrgUnit_Department_Model $o)
    {
        $objDepartment = $this->service->findByCode($o->getCode());
        $this->assertInstanceOf('D2LWS_OrgUnit_Department_Model', $objDepartment);        
        $this->assertEquals($o,$objDepartment);
    }
    
    /**
     * Attempt to fetch a non-existent OUID
     * @expectedException D2LWS_OrgUnit_Department_Exception_NotFound
     */
    public function testFindByCodeWhichDoesNotExist()
    {
        $objDepartment = $this->service->findByCode(md5(uniqid("")));
    }
}
{'fraction_non_alphanumeric': 0.10683933630109267, 'fraction_numerical': 0.011533791987049777, 'mean_word_length': 2.867762128325509, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 58, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4819682', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1503, 'n_words': 379}