@@ -674,4 +674,84 @@ public function testListUsersColumnsWithoutTenancyId()
674
674
$ test ->get ('/users?columns=username,location ' );
675
675
$ test ->expect ('{"users":{"columns":["username","location"],"records":[["user1","POINT(30 20)"]]}} ' );
676
676
}
677
+
678
+ public function testTenancyCreateColumns ()
679
+ {
680
+ // creation should fail, since due to tenancy function it will try to create with id=1, which is a PK and is already taken
681
+ $ test = new Api ($ this );
682
+ $ test ->post ('/users?columns=username,password,location ' , '{"username":"user3","password":"pass3","location":null} ' );
683
+ $ test ->expect ('null ' );
684
+ }
685
+
686
+ public function testTenancyCreateExclude ()
687
+ {
688
+ // creation should fail, since due to tenancy function it will try to create with id=1, which is a PK and is already taken
689
+ $ test = new Api ($ this );
690
+ $ test ->post ('/users?exclude=id ' , '{"username":"user3","password":"pass3","location":null} ' );
691
+ $ test ->expect ('null ' );
692
+ }
693
+
694
+ public function testTenancyListColumns ()
695
+ {
696
+ // should list only user with id=1 (exactly 1 record)
697
+ $ test = new Api ($ this );
698
+ $ test ->get ('/users?columns=username,location ' );
699
+ $ test ->expect ('{"users":{"columns":["username","location"],"records":[["user1",null]]}} ' );
700
+ }
701
+
702
+ public function testTenancyListExclude ()
703
+ {
704
+ // should list only user with id=1 (exactly 1 record)
705
+ $ test = new Api ($ this );
706
+ $ test ->get ('/users?exclude=id ' );
707
+ $ test ->expect ('{"users":{"columns":["username","location"],"records":[["user1",null]]}} ' );
708
+ }
709
+
710
+ public function testTenancyReadColumns ()
711
+ {
712
+ // should fail, since due to tenancy function user id=2 is unvailable to us
713
+ $ test = new Api ($ this );
714
+ $ test ->get ('/users/2?columns=username,location ' );
715
+ $ test ->expect (false , 'Not found (object) ' );
716
+ }
717
+
718
+ public function testTenancyReadExclude ()
719
+ {
720
+ // should fail, since due to tenancy function user id=2 is unvailable to us
721
+ $ test = new Api ($ this );
722
+ $ test ->get ('/users/2?exclude=id ' );
723
+ $ test ->expect (false , 'Not found (object) ' );
724
+ }
725
+
726
+ public function testTenancyUpdateColumns ()
727
+ {
728
+ // should fail, since due to tenancy function user id=2 is unvailable to us
729
+ $ test = new Api ($ this );
730
+ $ test ->put ('/users/2?columns=location ' , '{"location":"somelocation"} ' );
731
+ $ test ->expect ('0 ' );
732
+ }
733
+
734
+ public function testTenancyUpdateExclude ()
735
+ {
736
+ // should fail, since due to tenancy function user id=2 is unvailable to us
737
+ $ test = new Api ($ this );
738
+ $ test ->put ('/users/2?exclude=id ' , '{"location":"somelocation"} ' );
739
+ $ test ->expect ('0 ' );
740
+ }
741
+
742
+ public function testTenancyDeleteColumns ()
743
+ {
744
+ // should fail, since due to tenancy function user id=2 is unvailable to us
745
+ $ test = new Api ($ this );
746
+ $ test ->delete ('/users/2?columns=location ' );
747
+ $ test ->expect ('0 ' );
748
+ }
749
+
750
+ public function testTenancyDeleteExclude ()
751
+ {
752
+ // should fail, since due to tenancy function user id=2 is unvailable to us
753
+ $ test = new Api ($ this );
754
+ $ test ->delete ('/users/2?exclude=id ' );
755
+ $ test ->expect ('0 ' );
756
+ }
677
757
}
0 commit comments