PHP Classes

File: tests/unit/Sql/SelectTest.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   tests/unit/Sql/SelectTest.php   Download  
File: tests/unit/Sql/SelectTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 1,437 bytes
 

Contents

Class file image Download
<?php

class Sql_SelectTest extends UnitTestCase {
   
    function
setUp() {
    }
   
    function
TearDown() {
    }

    function
testSql_SelectColumns() {
       
$Sql_Select = new A_Sql_Select();
       
$this->assertEqual($Sql_Select
                           
->columns('foo', 'bar')
                            ->
from('foobar')
                            ->
render(), "SELECT foo, bar FROM foobar");

       
$Sql_Select = new A_Sql_Select();
       
$this->assertEqual($Sql_Select
                           
->columns(array('foo', 'bar'))
                            ->
from('foobar')
                            ->
render(), "SELECT foo, bar FROM foobar");
    }

    function
testSql_SelectWhere() {
       
$Sql_Select = new A_Sql_Select();
       
$this->assertEqual($Sql_Select
                           
->columns('foo', 'bar')
                            ->
from('foobar')
                            ->
where('baz', 'faz')
                            ->
render(), "SELECT foo, bar FROM foobar WHERE (baz = 'faz')");

       
$Sql_Select = new A_Sql_Select();
       
$this->assertEqual($Sql_Select
                           
->columns('foo', 'bar')
                            ->
from('foobar')
                            ->
where(array('baz LIKE '=>'faz', 'start = NOW()'))
                            ->
render(), "SELECT foo, bar FROM foobar WHERE (baz LIKE 'faz' AND start = NOW())");
    }
   
    function
testSql_SelectJoins() {

       
$Sql_Select = new A_Sql_Select();
       
$this->assertEqual($Sql_Select
                           
->columns('foo', 'bar')
                            ->
from('foobar')
                            ->
join('barfoo', 'foobar', 'LEFT')
                            ->
on('foobar_id', 'id')
                            ->
render(), "SELECT foo, bar FROM foobar LEFT JOIN barfoo ON (barfoo.foobar_id = foobar.id)");

    }
   
}