ultimix
unit_tests.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
26  class unit_tests{
27 
38  var $ErrorLogAccess = false;
39 
50  function set_up()
51  {
52  $this->ErrorLogAccess = get_package( 'error_log::error_log_access' , 'last' , __FILE__ );
53  }
54 
69  function test_add()
70  {
71  try
72  {
73  $this->ErrorLogAccess->add_message_to_log( 1 , 'title' , 'description' );
74  $Messages = $this->ErrorLogAccess->unsafe_select_messages( '1 ORDER BY id DESC LIMIT 0 , 1' );
75 
76  if( count( $Messages ) != 1 )
77  {
78  return( 'Illegal messages count' );
79  }
80 
81  $Message = $Messages[ 0 ];
82  if( $Message->severity != 1 || $Message->title != 'title' || $Message->description != 'description' )
83  {
84  return( 'Illegal field value' );
85  }
86 
87  $this->ErrorLogAccess->delete_error_log( $Message->id );
88 
89  return( 'TEST PASSED' );
90  }
91  catch( Exception $e )
92  {
93  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
94  }
95  }
96 
111  function test_delete()
112  {
113  try
114  {
115  $this->ErrorLogAccess->add_message_to_log( 1 , 'title' , 'description' );
116  $Messages = $this->ErrorLogAccess->unsafe_select_messages( '1 ORDER BY id DESC LIMIT 0 , 1' );
117 
118  if( count( $Messages ) != 1 )
119  {
120  return( 'Illegal messages count' );
121  }
122 
123  $this->ErrorLogAccess->delete_error_log( $Messages[ 0 ]->id );
124 
125  $id = $Messages[ 0 ]->id;
126 
127  $Messages = $this->ErrorLogAccess->unsafe_select_messages( '1 ORDER BY id DESC LIMIT 0 , 1' );
128 
129  if( isset( $Messages[ 0 ] ) !== false && $Messages[ 0 ]->id > $id )
130  {
131  return( 'Message was not deleted' );
132  }
133 
134  return( 'TEST PASSED' );
135  }
136  catch( Exception $e )
137  {
138  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
139  }
140  }
141  }
142 
143 ?>