PHP Classes

File: tests/eMapper/PostgreSQL/Mapper/ScalarMapper/StringTypeTest.php

Recommend this page to a friend!
  Classes of Emmanuel Antico   eMapper   tests/eMapper/PostgreSQL/Mapper/ScalarMapper/StringTypeTest.php   Download  
File: tests/eMapper/PostgreSQL/Mapper/ScalarMapper/StringTypeTest.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: Added: Abstract type tests.
Date: 9 years ago
Size: 2,515 bytes
 

Contents

Class file image Download
<?php
namespace eMapper\PostgreSQL\Mapper\ScalarMapper;

use
eMapper\PostgreSQL\PostgreSQLConfig;
use
eMapper\Mapper\ScalarMapper\AbstractStringTypeTest;

/**
 * Tests Mapper class with string values
 * @author emaphp
 * @group postgre
 * @group mapper
 * @group string
 */
class StringTypeTest extends AbstractStringTypeTest {
    use
PostgreSQLConfig;
   
    public function
testString() {
       
$value = $this->mapper->type('string')->query("SELECT 'hello'");
       
$this->assertEquals('hello', $value);
   
       
$value = $this->mapper->type('str')->query("SELECT user_name FROM users WHERE user_id = 3");
       
$this->assertEquals('jkirk', $value);
   
       
$value = $this->mapper->type('s', 'user_name')->query("SELECT * FROM users WHERE user_id = 5");
       
$this->assertEquals('ishmael', $value);
   
       
$result = $this->mapper->type('s')->query("SELECT user_id FROM users WHERE user_name = 'jdoe'");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('1', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT birth_date FROM users WHERE user_name = 'jdoe'");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('1987-08-10', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT last_login FROM users WHERE user_name = 'jdoe'");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('2013-08-10 19:57:15', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT newsletter_time FROM users WHERE user_name = 'jdoe'");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('12:00:00', $result);
           
       
$result = $this->mapper->type('s')->query("SELECT price FROM products WHERE product_id = 1");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('150.65', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT rating FROM products WHERE product_id = 1");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('4.5', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT refurbished FROM products WHERE product_id = 1");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('f', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT manufacture_year FROM products WHERE product_id = 1");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('2011', $result);
   
       
$result = $this->mapper->type('s')->query("SELECT discount FROM sales WHERE sale_id = 1");
       
$this->assertInternalType('string', $result);
       
$this->assertEquals('0.25', $result);
    }
}
?>