Commit ead2248 arutyunyan
committed
1 parent ce59a10 commit ead2248 Copy full SHA for ead2248
File tree 4 files changed +57
-0
lines changed
4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use PHPUnit \Framework \TestCase ;
6
+ use sagittaracc \StringHelper ;
7
+ use test \suql \models \Query30 ;
8
+
9
+ final class MacrosTest extends TestCase
10
+ {
11
+ /**
12
+ * Example:
13
+ *
14
+ * select
15
+ * table.f1,
16
+ * table.f2
17
+ * from table
18
+ *
19
+ */
20
+ public function testSelectFieldList (): void
21
+ {
22
+ $ expected = StringHelper::trimSql (require ('queries/mysql/q42.php ' ));
23
+ $ actual = Query30::all ()->macros1 ('param1 ' )->getRawSql ();
24
+ $ this ->assertEquals ($ expected , $ actual );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ return [
4
+ 'param1 ' => function ($ query ) {
5
+ $ query ->select (['f1 ' , 'f2 ' ]);
6
+ },
7
+ ];
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace test \suql \models ;
4
+
5
+ use suql \builder \MySQLBuilder ;
6
+ use suql \syntax \entity \SuQLTable ;
7
+ use test \suql \schema \AppScheme ;
8
+
9
+ # [Table(name="table_30")]
10
+ class Query30 extends SuQLTable
11
+ {
12
+ protected static $ schemeClass = AppScheme::class;
13
+ protected static $ builderClass = MySQLBuilder::class;
14
+
15
+ protected $ useMacros = true ;
16
+ protected $ macrosPath = 'tests/suql/macros ' ;
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ return <<<SQL
3
+ select
4
+ `table_30`.`f1`,
5
+ `table_30`.`f2`
6
+ from `table_30`
7
+ SQL ;
You can’t perform that action at this time.
0 commit comments