File tree Expand file tree Collapse file tree 6 files changed +15
-13
lines changed Expand file tree Collapse file tree 6 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,8 @@ protected function attachByMethod(string $method)
97
97
{
98
98
if ($ this ->$ method ) {
99
99
foreach ($ this ->$ method as $ attachModel ) {
100
- $ attachModel = __NAMESPACE__ . '\\' . $ attachModel ;
100
+ $ class = new \ReflectionClass ($ this );
101
+ $ attachModel = $ class ->getNamespaceName () . '\\' . $ attachModel ;
101
102
$ attach = new $ attachModel ($ this ->mysql );
102
103
foreach ($ this ->data as $ key => $ model ) {
103
104
switch ($ method ) {
@@ -136,7 +137,8 @@ protected function attachHABTM()
136
137
{
137
138
if ($ this ->hasAndBelongsToMany ) {
138
139
foreach ($ this ->hasAndBelongsToMany as $ habtmModel ) {
139
- $ habtmModel = __NAMESPACE__ . '\\' . $ habtmModel ;
140
+ $ class = new \ReflectionClass ($ this );
141
+ $ habtmModel = $ class ->getNamespaceName () . '\\' . $ habtmModel ;
140
142
$ habtm = new $ habtmModel ($ this ->mysql );
141
143
foreach ($ this ->data as $ key => $ model ) {
142
144
$ alias = $ habtm ->table . ' ' . $ habtm ->model ;
Original file line number Diff line number Diff line change 1
1
<?php
2
- namespace PHPRed \ Models ;
2
+ namespace Custom ;
3
3
4
- class Pipe extends Model
4
+ class Pipe extends \ PHPRed \ Models \ Model
5
5
{
6
6
public function __construct (\MysqliDb $ mysql )
7
7
{
Original file line number Diff line number Diff line change 1
1
<?php
2
- namespace PHPRed \ Models ;
2
+ namespace Custom ;
3
3
4
- class PipeUser extends Model
4
+ class PipeUser extends \ PHPRed \ Models \ Model
5
5
{
6
6
public function __construct (\MysqliDb $ mysql )
7
7
{
Original file line number Diff line number Diff line change 1
1
<?php
2
- namespace PHPRed \ Models ;
2
+ namespace Custom ;
3
3
4
- class Service extends Model
4
+ class Service extends \ PHPRed \ Models \ Model
5
5
{
6
6
public function __construct (\MysqliDb $ mysql )
7
7
{
Original file line number Diff line number Diff line change 1
1
<?php
2
- namespace PHPRed \ Models ;
2
+ namespace Custom ;
3
3
4
- class User extends Model
4
+ class User extends \ PHPRed \ Models \ Model
5
5
{
6
6
public function __construct (\MysqliDb $ mysql )
7
7
{
Original file line number Diff line number Diff line change @@ -57,13 +57,13 @@ public function setup()
57
57
]];
58
58
$ this ->prophet = new Prophecy \Prophet ;
59
59
$ this ->mysql = $ this ->prophet ->prophesize ("\MysqliDb " );
60
- $ this ->pipe = new Pipe ($ this ->mysql ->reveal ());
61
- $ this ->pipeUser = new PipeUser ($ this ->mysql ->reveal ());
60
+ $ this ->pipe = new \ Custom \ Pipe ($ this ->mysql ->reveal ());
61
+ $ this ->pipeUser = new \ Custom \ PipeUser ($ this ->mysql ->reveal ());
62
62
}
63
63
64
64
public function testCanInstantiate ()
65
65
{
66
- $ this ->assertInstanceOf (Pipe::class, $ this ->pipe );
66
+ $ this ->assertInstanceOf (\ Custom \ Pipe::class, $ this ->pipe );
67
67
}
68
68
69
69
public function testCanGetAll ()
You can’t perform that action at this time.
0 commit comments