@@ -34,7 +34,7 @@ private function action($method,$url,$data='')
34
34
'tenancy_function ' =>function ($ action ,$ database ,$ table ,$ column ) { return ($ table =='users ' &&$ column =='id ' )?1 :null ; },
35
35
'input_sanitizer ' =>function ($ action ,$ database ,$ table ,$ column ,$ type ,$ value ) { return is_string ($ value )?strip_tags ($ value ):$ value ; },
36
36
'input_validator ' =>function ($ action ,$ database ,$ table ,$ column ,$ type ,$ value ,$ context ) { return ($ column =='category_id ' && !is_numeric ($ value ))?'must be numeric ' :true ; },
37
- 'before ' =>function (&$ action ,&$ database ,&$ table ,&$ id ,&$ input ) { if ($ action =='create ' && $ input !==false ) $ input ->created_at = '2013-12-11 10:09:08 ' ; else if ($ action =='delete ' && $ table =='products ' ) { $ action ='update ' ; $ input = (object )array ('deleted_at ' => '2013-12-11 10:09:08 ' ); } },
37
+ 'before ' =>function (&$ action ,&$ database ,&$ table ,&$ id ,&$ input ) { if ($ action =='create ' && $ input !==false ) $ input ->created_at = '2013-12-11 10:09:08 ' ; else if ($ action =='delete ' && $ table =='products ' ) { $ action ='update ' ; $ input = (object )array ('deleted_at ' => '2013-12-11 11: 10:09 ' ); } },
38
38
'after ' =>function ($ action ,$ database ,$ table ,$ id ,$ input ,$ output ) { file_put_contents ('log.txt ' ,var_export (array ($ action ,$ database ,$ table ,$ id ,$ input ,$ output ),true ),FILE_APPEND ); },
39
39
// for tests
40
40
'method ' =>$ method ,
@@ -788,15 +788,15 @@ public function testAddProducts()
788
788
$ test ->post ('/products ' ,'{"name":"Laptop","price":"1299.99","properties":{}} ' );
789
789
$ test ->expect ('2 ' );
790
790
$ test ->get ('/products/2 ' );
791
- $ test ->expect ('{"id":2,"name":"Laptop","price":"1299.99","properties":{},"created_at":"2013-12-11 10:09:08"} ' );
791
+ $ test ->expect ('{"id":2,"name":"Laptop","price":"1299.99","properties":{},"created_at":"2013-12-11 10:09:08","deleted_at":null } ' );
792
792
}
793
793
794
794
public function testSoftDeleteProduct ()
795
795
{
796
796
$ test = new API ($ this );
797
797
$ test ->delete ('/products/2 ' );
798
- $ test ->expect ('2 ' );
799
- // $test->get('/products/2');
800
- // $test->expect('{"id":2,"name":"Laptop","price":"1299.99","properties":{},"created_at":"2013-12-11 10:09:08"}');
798
+ $ test ->expect ('1 ' );
799
+ $ test ->get ('/products/2 ' );
800
+ $ test ->expect ('{"id":2,"name":"Laptop","price":"1299.99","properties":{},"created_at":"2013-12-11 10:09:08","deleted_at":"2013-12-11 11:10:09 "} ' );
801
801
}
802
802
}
0 commit comments