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)
9797 {
9898 if ($ this ->$ method ) {
9999 foreach ($ this ->$ method as $ attachModel ) {
100- $ attachModel = __NAMESPACE__ . '\\' . $ attachModel ;
100+ $ class = new \ReflectionClass ($ this );
101+ $ attachModel = $ class ->getNamespaceName () . '\\' . $ attachModel ;
101102 $ attach = new $ attachModel ($ this ->mysql );
102103 foreach ($ this ->data as $ key => $ model ) {
103104 switch ($ method ) {
@@ -136,7 +137,8 @@ protected function attachHABTM()
136137 {
137138 if ($ this ->hasAndBelongsToMany ) {
138139 foreach ($ this ->hasAndBelongsToMany as $ habtmModel ) {
139- $ habtmModel = __NAMESPACE__ . '\\' . $ habtmModel ;
140+ $ class = new \ReflectionClass ($ this );
141+ $ habtmModel = $ class ->getNamespaceName () . '\\' . $ habtmModel ;
140142 $ habtm = new $ habtmModel ($ this ->mysql );
141143 foreach ($ this ->data as $ key => $ model ) {
142144 $ alias = $ habtm ->table . ' ' . $ habtm ->model ;
Original file line number Diff line number Diff line change 11<?php
2- namespace PHPRed \ Models ;
2+ namespace Custom ;
33
4- class Pipe extends Model
4+ class Pipe extends \ PHPRed \ Models \ Model
55{
66 public function __construct (\MysqliDb $ mysql )
77 {
Original file line number Diff line number Diff line change 11<?php
2- namespace PHPRed \ Models ;
2+ namespace Custom ;
33
4- class PipeUser extends Model
4+ class PipeUser extends \ PHPRed \ Models \ Model
55{
66 public function __construct (\MysqliDb $ mysql )
77 {
Original file line number Diff line number Diff line change 11<?php
2- namespace PHPRed \ Models ;
2+ namespace Custom ;
33
4- class Service extends Model
4+ class Service extends \ PHPRed \ Models \ Model
55{
66 public function __construct (\MysqliDb $ mysql )
77 {
Original file line number Diff line number Diff line change 11<?php
2- namespace PHPRed \ Models ;
2+ namespace Custom ;
33
4- class User extends Model
4+ class User extends \ PHPRed \ Models \ Model
55{
66 public function __construct (\MysqliDb $ mysql )
77 {
Original file line number Diff line number Diff line change @@ -57,13 +57,13 @@ public function setup()
5757 ]];
5858 $ this ->prophet = new Prophecy \Prophet ;
5959 $ 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 ());
6262 }
6363
6464 public function testCanInstantiate ()
6565 {
66- $ this ->assertInstanceOf (Pipe::class, $ this ->pipe );
66+ $ this ->assertInstanceOf (\ Custom \ Pipe::class, $ this ->pipe );
6767 }
6868
6969 public function testCanGetAll ()
You can’t perform that action at this time.
0 commit comments