Login   Register  
PHP Classes
elePHPant
Icontem

File: classes/test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Miguel Villaseņor  >  MKCS PHP Support Chat  >  classes/test.php  >  Download  
File: classes/test.php
Role: Example script
Content type: text/plain
Description: Unit test script
Class: MKCS PHP Support Chat
Chat with clients of a support site
Author: By
Last change:
Date: 1 year ago
Size: 1,992 bytes
 

Contents

Class file image Download
<?php
include 'Client.php';
include 
'User.php';
$option 'opcion';
if(isset(
$argv[1]))
    
$option=$argv[1];

try{
switch(
$option){
    case 
"add-client":
        
$clientClient::getNewClient($argv[2], $argv[3]);
        if(
$client)echo "Done! id=".$client->id;
        break;
    case 
"get-client":
        
$clientClient::getClient($argv[2]);
        if(
$clientprint_r($client);
        break;
    case 
"get-client-chat":
        
$clientClient::getClient($argv[2]);
        if(
$clientprint_r($client->getChat());
        break;
    case 
"get-unasigned":
        
$chatsChat::getUnasignedChats();
        if(
$chatsprint_r($chats);
        break;
    case 
"add-user":
        
$userUser::getNewUser($argv[2], $argv[3], $argv[4]);
        if(
$user)echo "Done! id=".$user->id;
        break;
    case 
"get-user":
        
$userUser::getUser($argv[2]);
        if(
$user)print_r($user);
        break;
    case 
"val-user":
        
$userUser::validateUser($argv[2],$argv[3]);
        echo 
$user?"valid":"invalid";
        break;
    case 
"chat-assign":
        
$chat Chat::getExistingChat($argv[2]) ;
        if(
$chat->setUser($argv[3]))
            echo 
$chat->getUser();
        else {
            echo 
"Error";
        }
        break;
    case 
"client-msg":
        
$userClient::getClient($argv[2]);
        if(
$user->sendMessage($argv[3]))
            echo 
$user->getLastActivity();
        else {
            echo 
"Error";
        }
        break;
    case 
"user-msg":
        
$userUser::getUser($argv[2]);
        if(
$user->sendMessage($argv[3],$argv[4]))
            echo 
$argv[3];
        else {
            echo 
"Error";
        }
        break;
    case 
"time":
        echo 
Db::getInstance()->getTimestamp();
        break;
    case 
"get-latest":
        echo 
print_r(Message::getLatestMessages($argv[2],$argv[3]));
        break;
    
    default:
        echo 
"unexisting function";
        break;
}
}catch(
Exception $e){
    echo 
"Error: ".$e->getMessage();
}