@@ -24,28 +24,18 @@ public function testSelectCount() : void
24
24
$ this ->assertEquals ('Company A ' , $ dataObjectCursor ->current ()->company );
25
25
}
26
26
27
- public function testSelectWhere () : void
27
+ public function testSelectGroupBy () : void
28
28
{
29
- $ table = new \Tests \App \Table \Customer ();
30
- $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , 'Purchasing Manager ' ));
31
- $ this ->assertEquals (13 , $ table ->count ());
32
-
33
- $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \Like ()));
34
- $ this ->assertEquals (20 , $ table ->count ());
35
-
36
- $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \NotLike ()));
37
- $ this ->assertEquals (9 , $ table ->count ());
38
-
39
- $ condition = new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \Like ());
40
- $ condition ->and (new \PHPFUI \ORM \Condition ('state_province ' , 'NY ' ));
41
- $ table ->setWhere ($ condition );
42
- $ this ->assertEquals (2 , $ table ->count ());
43
-
44
- $ condition = new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \NotLike ());
45
- $ condition ->or (new \PHPFUI \ORM \Condition ('state_province ' , 'NY ' ));
46
- $ table ->setWhere ($ condition );
47
- $ this ->assertEquals (11 , \count ($ table ));
48
- $ this ->assertEquals (11 , $ table ->count ());
29
+ $ table = new \Tests \App \Table \InventoryTransaction ();
30
+ $ table ->addSelect ('category ' );
31
+ $ table ->addSelect (new \PHPFUI \ORM \Literal ('count(*) ' ), 'count ' );
32
+ $ table ->addJoin ('product ' );
33
+ $ table ->addGroupBy ('category ' );
34
+ $ table ->addOrderBy ('count ' , 'desc ' );
35
+ $ this ->assertEquals (14 , $ table ->count ());
36
+ $ record = $ table ->getDataObjectCursor ()->current ();
37
+ $ this ->assertEquals (26 , $ record ->count );
38
+ $ this ->assertEquals ('Beverages ' , $ record ->category );
49
39
}
50
40
51
41
public function testSelectIn () : void
@@ -58,14 +48,29 @@ public function testSelectIn() : void
58
48
$ this ->assertEquals (6 , $ orderTable ->count ());
59
49
}
60
50
61
- public function testSelectNotIn () : void
51
+ public function testSelectJoin () : void
62
52
{
63
- $ orderDetailTable = new \Tests \App \Table \OrderDetail ();
64
- $ orderDetailTable ->setWhere (new \PHPFUI \ORM \Condition ('quantity ' , 10 ));
65
- $ orderDetailTable ->addSelect ('order_id ' );
66
- $ orderTable = new \Tests \App \Table \Order ();
67
- $ orderTable ->setWhere (new \PHPFUI \ORM \Condition ('order_id ' , $ orderDetailTable , new \PHPFUI \ORM \Operator \NotIn ()));
68
- $ this ->assertEquals (42 , $ orderTable ->count ());
53
+ $ table = new \Tests \App \Table \InventoryTransaction ();
54
+ $ table ->addJoin ('inventory_transaction_type ' );
55
+ $ table ->addJoin ('order ' );
56
+ $ table ->addJoin ('product ' );
57
+ $ table ->addJoin ('purchase_order ' );
58
+
59
+ $ table ->setLimit (10 );
60
+ $ this ->assertEquals (10 , $ table ->count ());
61
+ $ this ->assertEquals (102 , $ table ->total ());
62
+ $ record = $ table ->getDataObjectCursor ()->current ();
63
+
64
+ $ this ->assertEquals (10 , $ table ->count ());
65
+ $ this ->assertEquals (3.5 , $ record ->list_price );
66
+ $ this ->assertEquals (25 , $ record ->minimum_reorder_quantity );
67
+ $ this ->assertEquals ('NWTDFN-80 ' , $ record ->product_code );
68
+ $ this ->assertEquals (80 , $ record ->product_product_id );
69
+ $ this ->assertEquals ('Northwind Traders Dried Plums ' , $ record ->product_name );
70
+ $ this ->assertEquals ('1 lb bag ' , $ record ->quantity_per_unit );
71
+ $ this ->assertEquals (50 , $ record ->reorder_level );
72
+ $ this ->assertEquals (3 , $ record ->standard_cost );
73
+ $ this ->assertEquals (75 , $ record ->target_level );
69
74
}
70
75
71
76
// this fails under sqlite for some reason. The count clause returns 0 for unknown reasons. Commented out for now.
@@ -103,43 +108,14 @@ public function testSelectLimitOrderBy() : void
103
108
$ this ->assertEquals (96 , $ table ->getRecordCursor ()->current ()->inventory_transaction_id );
104
109
}
105
110
106
- public function testSelectGroupBy () : void
107
- {
108
- $ table = new \Tests \App \Table \InventoryTransaction ();
109
- $ table ->addSelect ('category ' );
110
- $ table ->addSelect (new \PHPFUI \ORM \Literal ('count(*) ' ), 'count ' );
111
- $ table ->addJoin ('product ' );
112
- $ table ->addGroupBy ('category ' );
113
- $ table ->addOrderBy ('count ' , 'desc ' );
114
- $ this ->assertEquals (14 , $ table ->count ());
115
- $ record = $ table ->getDataObjectCursor ()->current ();
116
- $ this ->assertEquals (26 , $ record ->count );
117
- $ this ->assertEquals ('Beverages ' , $ record ->category );
118
- }
119
-
120
- public function testSelectJoin () : void
111
+ public function testSelectNotIn () : void
121
112
{
122
- $ table = new \Tests \App \Table \InventoryTransaction ();
123
- $ table ->addJoin ('inventory_transaction_type ' );
124
- $ table ->addJoin ('order ' );
125
- $ table ->addJoin ('product ' );
126
- $ table ->addJoin ('purchase_order ' );
127
-
128
- $ table ->setLimit (10 );
129
- $ this ->assertEquals (10 , $ table ->count ());
130
- $ this ->assertEquals (102 , $ table ->total ());
131
- $ record = $ table ->getDataObjectCursor ()->current ();
132
-
133
- $ this ->assertEquals (10 , $ table ->count ());
134
- $ this ->assertEquals (3.5 , $ record ->list_price );
135
- $ this ->assertEquals (25 , $ record ->minimum_reorder_quantity );
136
- $ this ->assertEquals ('NWTDFN-80 ' , $ record ->product_code );
137
- $ this ->assertEquals (80 , $ record ->product_product_id );
138
- $ this ->assertEquals ('Northwind Traders Dried Plums ' , $ record ->product_name );
139
- $ this ->assertEquals ('1 lb bag ' , $ record ->quantity_per_unit );
140
- $ this ->assertEquals (50 , $ record ->reorder_level );
141
- $ this ->assertEquals (3 , $ record ->standard_cost );
142
- $ this ->assertEquals (75 , $ record ->target_level );
113
+ $ orderDetailTable = new \Tests \App \Table \OrderDetail ();
114
+ $ orderDetailTable ->setWhere (new \PHPFUI \ORM \Condition ('quantity ' , 10 ));
115
+ $ orderDetailTable ->addSelect ('order_id ' );
116
+ $ orderTable = new \Tests \App \Table \Order ();
117
+ $ orderTable ->setWhere (new \PHPFUI \ORM \Condition ('order_id ' , $ orderDetailTable , new \PHPFUI \ORM \Operator \NotIn ()));
118
+ $ this ->assertEquals (42 , $ orderTable ->count ());
143
119
}
144
120
145
121
public function testSelectUnion () : void
@@ -155,4 +131,28 @@ public function testSelectUnion() : void
155
131
$ this ->assertEquals (18 , $ table ->count ());
156
132
$ this ->assertEquals ('Allocated ' , $ table ->getDataObjectCursor ()->current ()->name );
157
133
}
134
+
135
+ public function testSelectWhere () : void
136
+ {
137
+ $ table = new \Tests \App \Table \Customer ();
138
+ $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , 'Purchasing Manager ' ));
139
+ $ this ->assertEquals (13 , $ table ->count ());
140
+
141
+ $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \Like ()));
142
+ $ this ->assertEquals (20 , $ table ->count ());
143
+
144
+ $ table ->setWhere (new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \NotLike ()));
145
+ $ this ->assertEquals (9 , $ table ->count ());
146
+
147
+ $ condition = new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \Like ());
148
+ $ condition ->and (new \PHPFUI \ORM \Condition ('state_province ' , 'NY ' ));
149
+ $ table ->setWhere ($ condition );
150
+ $ this ->assertEquals (2 , $ table ->count ());
151
+
152
+ $ condition = new \PHPFUI \ORM \Condition ('job_title ' , '%Purchasing% ' , new \PHPFUI \ORM \Operator \NotLike ());
153
+ $ condition ->or (new \PHPFUI \ORM \Condition ('state_province ' , 'NY ' ));
154
+ $ table ->setWhere ($ condition );
155
+ $ this ->assertEquals (11 , \count ($ table ));
156
+ $ this ->assertEquals (11 , $ table ->count ());
157
+ }
158
158
}
0 commit comments