PHP Classes

File: tests/unit/Sql/UpdateTest.php

Recommend this page to a friend!
  Packages of Haseeb Ahmad Basil   PHP Skeleton Framework   tests/unit/Sql/UpdateTest.php   Download  
File: tests/unit/Sql/UpdateTest.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: 10 years ago
Size: 1,264 bytes
 

Contents

Class file image Download
<?php

class Sql_UpdateTest extends UnitTestCase {
    
    function setUp() {
    }
    
    function TearDown() {
    }
    
    function testSql_UpdateSet() {
        $Sql_Update = new A_Sql_Update();
        $this->assertEqual($Sql_Update->table('foobar')->set('foo', 'bar')->render(), "UPDATE foobar SET foo = 'bar'");

        $Sql_Update = new A_Sql_Update();
        $this->assertEqual($Sql_Update->table('foobar')->set('foo', "bar's")->render(), "UPDATE foobar SET foo = 'bar\\'s'");

        // sets do not overwrite previous sets
        $Sql_Update = new A_Sql_Update();
        $this->assertEqual($Sql_Update
                            ->table('foobar')
                            ->set('foo', 'bar')
                            ->set('baz', 'faz')
                            ->render(), "UPDATE foobar SET foo = 'bar', baz = 'faz'");

            // sets do not overwrite previous sets
        $Sql_Update = new A_Sql_Update();
        $this->assertEqual($Sql_Update
                            ->table('foobar')
                            ->set(array('foo'=>'bar', 'baz'=>'faz'))
                            ->render(), "UPDATE foobar SET foo = 'bar', baz = 'faz'");
    }
    
    function testSql_UpdateWhere() {
        $Sql_Update = new A_Sql_Update();
        $this->assertEqual($Sql_Update
                            ->table('foobar')
                            ->set('foo', 'bar')
                            ->where('baz', 'faz')
                            ->render(), "UPDATE foobar SET foo = 'bar' WHERE (baz = 'faz')");
    }
    
}