<commit_before><?php

namespace Tsf\Dao;

require_once dirname(__FILE__) . '/../../../../library/Tsf/Dao/ImageDao.php';

/**
 * Test class for ImageDao.
 * Generated by PHPUnit on 2012-08-15 at 22:52:25.
 */
class ImageDaoTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @var ImageDao
     */
    protected $dao;

    /**
     * @var \PDO
     */
    protected $db;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->db = new \PDO('sqlite::memory:');
        $this->db->exec(file_get_contents(realpath(__DIR__ . '/../../../_files/flaming_archer.sql')));
        $this->dao = new ImageDao($this->db);
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        $this->dao = null;
        $this->db = null;
    }
    
    /**
     * @covers Tsf\Dao\ImageDao::find
     * @todo Implement testFind().
     */
    public function testFind()
    {
        $result = $this->dao->find(1);
        $this->assertInternalType('array', $result);
        $this->assertEquals(1, $result['day']);
        $this->assertEquals(7606616668, $result['photo_id']);
    }

    /**
     * @covers Tsf\Dao\ImageDao::findAll
     * @todo Implement testFindAll().
     */
    public function testFindAll()
    {
        $result = $this->dao->findAll();
        $this->assertInternalType('array', $result);
        $this->assertEquals(7, count($result));
    }

    /**
     * @covers Tsf\Dao\ImageDao::save
     * @todo Implement testSave().
     */
    public function testSave()
    {
        $result = $this->dao->save(array('day' => 200, 'photo_id' => 999999));
        $this->assertEquals(1, $result);
        
        $image = $this->dao->find(200);
        $this->assertEquals(200, $image['day']);
    }

    /**
     * @covers Tsf\Dao\ImageDao::delete
     * @todo Implement testDelete().
     */
    public function testDelete()
    {
        $result = $this->dao->findAll();
        $this->assertEquals(7, count($result));
        
        $result = $this->dao->delete(1);
        $this->assertEquals(1, $result);
        
        $result = $this->dao->find(1);
        $this->assertFalse($result);
        
        $result = $this->dao->findAll();
        $this->assertEquals(6, count($result));
    }

}<commit_msg>Implements tests<commit_after><?php

namespace Tsf\Dao;

/**
 * Test class for ImageDao.
 * Generated by PHPUnit on 2012-08-15 at 22:52:25.
 */
class ImageDaoTest extends \CommonDbTestCase
{

    /**
     * @var ImageDao
     */
    protected $dao;

    /**
     * @var \PDO
     */
    protected $db;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        parent::setUp();
        $this->dao = new ImageDao($this->db);
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
        $this->dao = null;
        parent::tearDown();
    }
    
    public function testConstruct()
    {
        $this->assertInstanceOf('\Tsf\Dao\ImageDao', $this->dao);
    }

    /**
     * @covers Tsf\Dao\ImageDao::find
     */
    public function testFind()
    {
        $result = $this->dao->find(1);
        $this->assertInternalType('array', $result);
        $this->assertEquals(1, $result['day']);
        $this->assertEquals(7606616668, $result['photo_id']);
    }

    /**
     * @covers Tsf\Dao\ImageDao::findAll
     */
    public function testFindAll()
    {
        $result = $this->dao->findAll();
        $this->assertInternalType('array', $result);
        $this->assertEquals(7, count($result));
    }

    /**
     * @covers Tsf\Dao\ImageDao::save
     */
    public function testSave()
    {
        $result = $this->dao->save(array('day' => 200, 'photo_id' => 999999));
        $this->assertEquals(1, $result);

        $image = $this->dao->find(200);
        $this->assertEquals(200, $image['day']);
    }

    /**
     * @covers Tsf\Dao\ImageDao::delete
     */
    public function testDelete()
    {
        $this->assertEquals(7, count($this->dao->findAll()));
        $this->assertEquals(1, $this->dao->delete(1));
        $this->assertFalse($this->dao->find(1));
        $this->assertEquals(6, count($this->dao->findAll()));
    }

}
{'fraction_non_alphanumeric': 0.1727509778357236, 'fraction_numerical': 0.020860495436766623, 'mean_word_length': 2.1722949689869058, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 73, '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': '5549294', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1492, 'n_words': 292}