File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33Entity relationships for CodeIgniter 4
44
5- [ ![ ] ( https://github.com/tattersoftware/codeigniter4-relations/workflows/PHPUnit/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-relations/actions?query=workflow%3A%22PHPUnit )
5+ [ ![ ] ( https://github.com/tattersoftware/codeigniter4-relations/workflows/PHPUnit/badge.svg )] ( https://github.com/tattersoftware/codeigniter4-relations/actions?query=workflow%3APHPUnit )
66
77
88## Quick Start
Original file line number Diff line number Diff line change @@ -37,10 +37,13 @@ class DatabaseTestCase extends CIDatabaseTestCase
3737 public function setUp (): void
3838 {
3939 parent ::setUp ();
40-
40+
41+ cache ()->clean ();
42+
4143 // Configure and inject the Schemas service
4244 $ config = new \Tatter \Schemas \Config \Schemas ();
4345 $ config ->silent = false ;
46+ $ config ->ignoredNamespaces = [];
4447
4548 $ schemas = new \Tatter \Schemas \Schemas ($ config );
4649 Services::injectMock ('schemas ' , $ schemas );
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public function setUp(): void
1717 // Configure and inject the Schemas service
1818 $ config = new \Tatter \Schemas \Config \Schemas ();
1919 $ config ->silent = false ;
20+ $ config ->ignoredNamespaces = [];
2021
2122 $ schemas = new \Tatter \Schemas \Schemas ($ config );
2223 Services::injectMock ('schemas ' , $ schemas );
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ class MagicTest extends DatabaseTestCase
1111 public function setUp (): void
1212 {
1313 parent ::setUp ();
14-
15- $ this ->factories = new ArrayModel ();
16- $ this ->factory = new Factory ($ this ->factories -> find ( 1 ) );
14+
15+ $ this ->row = $ this -> db -> table ( ' factories ' )-> where ( ' id ' , 1 )-> get ()-> getRowArray ();
16+ $ this ->factory = new Factory ($ this ->row );
1717
1818 $ this ->machines = new MachineModel ();
1919 $ this ->machine = new Machine ((array ) $ this ->machines ->with (false )->find (7 ));
@@ -26,12 +26,10 @@ public function testGetIgnoresUnmatched()
2626
2727 public function testRequiresProperties ()
2828 {
29- $ row = $ this ->factories ->find (1 );
30-
3129 $ this ->expectException (RelationsException::class);
3230 $ this ->expectExceptionMessage ('Class Tests\Support\Entities\Propertyless must have the table property to use relations ' );
3331
34- $ factory = (new Propertyless ($ row ))->_getRelationship ('foobar ' );
32+ $ factory = (new Propertyless ($ this -> row ))->_getRelationship ('foobar ' );
3533 }
3634
3735 public function testGetSuccess ()
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ class ManyMethodsTest extends DatabaseTestCase
99 public function setUp (): void
1010 {
1111 parent ::setUp ();
12-
13- $ this ->factories = new ArrayModel ();
14- $ this ->factory = new Factory ($ this ->factories -> find ( 1 ) );
12+
13+ $ this ->row = $ this -> db -> table ( ' factories ' )-> where ( ' id ' , 1 )-> get ()-> getRowArray ();
14+ $ this ->factory = new Factory ($ this ->row );
1515 }
1616
1717 public function testHasAnySuccess ()
@@ -23,8 +23,9 @@ public function testHasAnySuccess()
2323
2424 public function testHasAnyFail ()
2525 {
26- $ factory = new Factory ($ this ->factories ->find (4 ));
27- $ method = $ this ->getPrivateMethodInvoker ($ factory , '_has ' );
26+ $ row = $ this ->db ->table ('factories ' )->where ('id ' , 4 )->get ()->getRowArray ();
27+ $ factory = new Factory ($ row );
28+ $ method = $ this ->getPrivateMethodInvoker ($ factory , '_has ' );
2829
2930 $ this ->assertFalse ($ method ('workers ' ));
3031 }
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ class RelationsTest extends DatabaseTestCase
1111 public function setUp (): void
1212 {
1313 parent ::setUp ();
14-
15- $ this ->factories = new ArrayModel ();
16- $ this ->factory = new Factory ($ this ->factories -> find ( 1 ) );
14+
15+ $ this ->row = $ this -> db -> table ( ' factories ' )-> where ( ' id ' , 1 )-> get ()-> getRowArray ();
16+ $ this ->factory = new Factory ($ this ->row );
1717 }
1818
1919 public function testUnknownTableFails ()
@@ -80,7 +80,7 @@ public function testArrayHasMany()
8080 $ servicers = new ServicerModel ();
8181 $ object = $ servicers ->with (false )->find (2 );
8282 $ servicer = new Servicer ((array ) $ object );
83-
83+
8484 $ lawyers = $ servicer ->relations ('lawyers ' );
8585
8686 $ this ->assertCount (3 , $ lawyers );
You can’t perform that action at this time.
0 commit comments