PHP Classes

File: tests/unit/Sql/FromTest.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   tests/unit/Sql/FromTest.php   Download  
File: tests/unit/Sql/FromTest.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: 2,153 bytes
 

Contents

Class file image Download
<?php

class Sql_FromTest extends UnitTestCase {
   
    function
setUp() {
    }
   
    function
TearDown() {
    }
   
    function
testSql_FromConstructor() {
         
$Sql_From = new A_Sql_From('foo');
        
$this->assertEqual($Sql_From->render(), "foo");

         
$Sql_From = new A_Sql_From(array('foo'));
        
$this->assertEqual($Sql_From->render(), "foo");

         
$Sql_From = new A_Sql_From(array('foo', 'bar'));
        
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar");

         
$Sql_From = new A_Sql_From(array('foo', new A_Sql_Join('bar')));
        
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar");
    }
   
    function
testSql_FromTable() {
         
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo');
        
$this->assertEqual($Sql_From->render(), "foo");

         
$Sql_From = new A_Sql_From();
       
$Sql_From->table(array('foo'));
         
$this->assertEqual($Sql_From->render(), "foo");

         
$Sql_From = new A_Sql_From();
       
$Sql_From->table(array('foo', 'bar'));
         
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar");

       
$Sql_From = new A_Sql_From();
       
$Sql_From->table(array('foo', new A_Sql_Join('bar')));
       
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar");
    }
   
    function
testSql_FromJoin() {
         
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo')->join('bar');
        
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar");

         
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo')->join('bar', 'LEFT');
         
$this->assertEqual($Sql_From->render(), "foo LEFT JOIN bar");

         
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo')->join('bar', 'foo', 'RIGHT');
         
$this->assertEqual($Sql_From->render(), "foo RIGHT JOIN bar");
    }
   
    function
testSql_FromJoinOn() {
       
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo')->join('bar', 'baz')->on('foo_id', 'id');
       
$this->assertEqual($Sql_From->render(), "foo INNER JOIN bar ON (bar.foo_id = baz.id)");
       
       
$Sql_From = new A_Sql_From();
       
$Sql_From->table('foo')->join(new A_Sql_Join('bar', 'baz', 'LEFT'))->on('foo_id', 'id');
       
$this->assertEqual($Sql_From->render(), "foo LEFT JOIN bar ON (bar.foo_id = baz.id)");
    }
   
}