@@ -33,28 +33,19 @@ public function testEndUse()
3333 {
3434
3535 $ query = $ this ->mockQueryInstance ();
36- $ use = new UseQueryFromDotNotation ($ query , "aName " );
37- $ use ->useQuery ();
38- $ this ->assertSame (0 , $ use ->getDepth ());
39- $ usedQuery = $ use ->endUse ();
40- $ this ->assertInstanceOf (\AQuery::class, $ usedQuery );
41- $ this ->assertSame ("AName " , $ use ->getProperty ());
42- $ this ->assertFalse ($ use ->isInUse ());
4336
44- $ use = new UseQueryFromDotNotation ($ query, " b.bName " );
45- $ use ->useQuery ();
37+ $ use = new UseQueryFromDotNotation ($ query );
38+ $ use ->fromString ( " b " )-> useQuery ();
4639 $ this ->assertSame (1 , $ use ->getDepth ());
4740 $ usedQuery = $ use ->endUse ();
4841 $ this ->assertInstanceOf (\AQuery::class, $ usedQuery );
49- $ this ->assertSame ("BName " , $ use ->getProperty ());
5042 $ this ->assertFalse ($ use ->isInUse ());
5143
52- $ use = new UseQueryFromDotNotation ($ query, " b.c.cName " );
53- $ use ->useQuery ();
44+ $ use = new UseQueryFromDotNotation ($ query );
45+ $ use ->fromString ( " b.c " )-> useQuery ();
5446 $ this ->assertSame (2 , $ use ->getDepth ());
5547 $ usedQuery = $ use ->endUse ();
5648 $ this ->assertInstanceOf (\AQuery::class, $ usedQuery );
57- $ this ->assertSame ("CName " , $ use ->getProperty ());
5849 $ this ->assertFalse ($ use ->isInUse ());
5950 }
6051
@@ -64,7 +55,7 @@ public function testEndUse()
6455 public function testEndUseBeforeUse ()
6556 {
6657 $ query = $ this ->mockQueryInstance ();
67- $ use = new UseQueryFromDotNotation ($ query, " zzz.foo " );
58+ $ use = new UseQueryFromDotNotation ($ query );
6859 $ this ->expectException (UseQueryFromDotNotationException::class);
6960 $ use ->endUse ();
7061 }
@@ -82,21 +73,27 @@ public function testSeparatorValue()
8273 */
8374 public function testUseQuery ()
8475 {
85- $ query = $ this ->mockQueryInstance ();
86- $ use = new UseQueryFromDotNotation ($ query , "foo " );
87- $ usedQuery = $ use ->useQuery ();
88- $ this ->assertInstanceOf (\AQuery::class, $ usedQuery );
89- $ this ->assertTrue (method_exists ($ usedQuery , "filterByAName " ));
76+ // $query = $this->mockQueryInstance();
77+ // $use = new UseQueryFromDotNotation($query, "foo");
78+ // $usedQuery = $use->useQuery();
79+ // $this->assertInstanceOf(\AQuery::class, $usedQuery);
80+ // $this->assertTrue(method_exists($usedQuery, "filterByAName"));
9081
9182 $ query = $ this ->mockQueryInstance ();
92- $ use = new UseQueryFromDotNotation ($ query , "b.foo " );
93- $ usedQuery = $ use ->useQuery ();
83+ $ use = new UseQueryFromDotNotation ($ query );
84+ $ usedQuery = $ use ->fromString ("b " )->useQuery ();
85+ $ this ->assertInstanceOf (\BQuery::class, $ usedQuery );
86+ $ this ->assertTrue (method_exists ($ usedQuery , "filterByBName " ));
87+
88+ $ query = $ this ->mockQueryInstance ();
89+ $ use = new UseQueryFromDotNotation ($ query );
90+ $ usedQuery = $ use ->fromArray (["b " ])->useQuery ();
9491 $ this ->assertInstanceOf (\BQuery::class, $ usedQuery );
9592 $ this ->assertTrue (method_exists ($ usedQuery , "filterByBName " ));
9693
9794 $ query = $ this ->mockQueryInstance ();
98- $ use = new UseQueryFromDotNotation ($ query, " b.c.foo " );
99- $ usedQuery = $ use ->useQuery ();
95+ $ use = new UseQueryFromDotNotation ($ query );
96+ $ usedQuery = $ use ->fromString ( " b.c " )-> useQuery ();
10097 $ this ->assertInstanceOf (\CQuery::class, $ usedQuery );
10198 $ this ->assertTrue (method_exists ($ usedQuery , "filterByCName " ));
10299 }
@@ -107,8 +104,8 @@ public function testUseQuery()
107104 public function testUseQueryAlreadyInUse ()
108105 {
109106 $ query = $ this ->mockQueryInstance ();
110- $ use = new UseQueryFromDotNotation ($ query, " b.foo " );
111- $ use ->useQuery ();
107+ $ use = new UseQueryFromDotNotation ($ query );
108+ $ use ->fromString ( " b " )-> useQuery ();
112109 $ this ->expectException (UseQueryFromDotNotationException::class);
113110 $ use ->useQuery ();
114111 }
@@ -119,30 +116,26 @@ public function testUseQueryAlreadyInUse()
119116 public function testUseQueryRelationNotFound ()
120117 {
121118 $ query = $ this ->mockQueryInstance ();
122- $ use = new UseQueryFromDotNotation ($ query, " zzz.foo " );
119+ $ use = new UseQueryFromDotNotation ($ query );
123120 $ this ->expectException (RelationNotFoundException::class);
124- $ use ->useQuery ();
125- }
126-
127- public function testUseQueryWithBadProperty ()
128- {
129- $ query = $ this ->mockQueryInstance ();
130- $ this ->expectException (\InvalidArgumentException::class);
131- new UseQueryFromDotNotation ($ query , "b. " );
121+ $ use ->fromString ("zzz " )->useQuery ();
132122 }
133123
134124 public function testUseQueryWithDotBeforeProperty ()
135125 {
136126 $ query = $ this ->mockQueryInstance ();
137- $ use = new UseQueryFromDotNotation ($ query , ".b " );
138- $ this ->assertSame (0 , $ use ->getDepth ());
127+ $ use = new UseQueryFromDotNotation ($ query );
128+ $ use ->fromString (".b " );
129+ $ this ->assertSame (1 , $ use ->getDepth ());
139130 }
140131
141132 public function testUseQueryWithEmptyProperty ()
142133 {
143134 $ query = $ this ->mockQueryInstance ();
144- $ this ->expectException (\InvalidArgumentException::class);
145- new UseQueryFromDotNotation ($ query , "" );
135+ $ use = new UseQueryFromDotNotation ($ query );
136+ $ use ->fromString ("" );
137+ $ this ->assertSame (0 , $ use ->getDepth ());
138+
146139 }
147140
148141 /**
0 commit comments