PHP Classes

File: tests/eMapper/SQLite/SQLiteTest.php

Recommend this page to a friend!
  Packages of Emmanuel Antico   eMapper   tests/eMapper/SQLite/SQLiteTest.php   Download  
File: tests/eMapper/SQLite/SQLiteTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: eMapper
Database abstraction layer that maps data types
Author: By
Last change:
Date: 12 years ago
Size: 1,216 bytes
 

 

Contents

Class file image Download
<?php
namespace eMapper\SQLite;

use Acme\Type\RGBColorTypeHandler;
use eMapper\SQL\Statement;
use eMapper\Engine\SQLite\SQLiteDriver;
use eMapper\Mapper;

abstract class SQLiteTest extends \PHPUnit_Framework_TestCase {
    public static $env_config = ['environment.id' => 'default', 'environment.class' => 'eMapper\Dynamic\Environment\DynamicSQLEnvironment'];
    
    public static $filename;
    public static $conn;
    public static $driver;
    public static $mapper;
    public static $blob;
    
    public static function setUpBeforeClass() {
        self::$filename = __DIR__ . '/testing.db';
        self::$conn = new \SQLite3(self::$filename);
        self::$driver = new SQLiteDriver(self::$filename);
        self::$mapper = new Mapper(self::$driver);
        self::$mapper->addType('Acme\RGBColor', new RGBColorTypeHandler(), 'color');
        self::$mapper->addStatement(new Statement('getProduct', "SELECT * FROM products WHERE product_id = #{productId}"));
        self::$mapper->addStatement(new Statement('getUser', "SELECT * FROM users WHERE user_id = %{int}", Statement::type('array')));
        
        self::$blob = file_get_contents(__DIR__ . '/../avatar.gif');
    }
    
    public static function tearDownAfterClass() {
        self::$conn->close();
        self::$mapper->close();
    }
}
?>