From 9454c546c474d7d473ac18843aea734c9811f2b7 Mon Sep 17 00:00:00 2001 From: macbre Date: Wed, 24 Mar 2021 18:13:07 +0100 Subject: [PATCH 1/5] Create Tests\App\Models\TestModel --- tests/app/{classes => models}/TestModel.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename tests/app/{classes => models}/TestModel.php (54%) diff --git a/tests/app/classes/TestModel.php b/tests/app/models/TestModel.php similarity index 54% rename from tests/app/classes/TestModel.php rename to tests/app/models/TestModel.php index e3a440ed..486e5c5c 100644 --- a/tests/app/classes/TestModel.php +++ b/tests/app/models/TestModel.php @@ -1,17 +1,17 @@ data = [ 'foo' => 'bar', From 4670052c56fe71abcd7bbc9dcf8d30f91d3742d6 Mon Sep 17 00:00:00 2001 From: macbre Date: Wed, 24 Mar 2021 21:55:14 +0100 Subject: [PATCH 2/5] Refactor ModelTest --- tests/ModelTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/ModelTest.php b/tests/ModelTest.php index fcc9a73f..43723de6 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -1,19 +1,23 @@ app = Nano::app($dir); } public function testGetMagic() { - $model = $this->app->factory('TestModel'); + $model = new TestModel(); $this->assertEquals($model->getData(), ['foo' => 'bar']); $this->assertEquals($model->getFoo(), 'bar'); From 5722b70b665633fc3fd1232c30499a81547a99cb Mon Sep 17 00:00:00 2001 From: macbre Date: Wed, 24 Mar 2021 21:58:53 +0100 Subject: [PATCH 3/5] TestModel class is loaded via autoloader --- tests/ModelTest.php | 15 +++++++++------ tests/app/{models => classes}/TestModel.php | 6 ++---- 2 files changed, 11 insertions(+), 10 deletions(-) rename tests/app/{models => classes}/TestModel.php (83%) diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 43723de6..4c4fcc46 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -9,17 +9,20 @@ */ class ModelTest extends NanoBaseTest { + /** + * @var TestModel + */ + private $model; + public function setUp(): void { - $dir = __DIR__ . '/app'; - $this->app = Nano::app($dir); + parent::setUp(); + $this->model = new TestModel(); } public function testGetMagic() { - $model = new TestModel(); - - $this->assertEquals($model->getData(), ['foo' => 'bar']); - $this->assertEquals($model->getFoo(), 'bar'); + $this->assertEquals(['foo' => 'bar'], $this->model->getData()); + $this->assertEquals('bar', $this->model->getFoo()); } } diff --git a/tests/app/models/TestModel.php b/tests/app/classes/TestModel.php similarity index 83% rename from tests/app/models/TestModel.php rename to tests/app/classes/TestModel.php index 486e5c5c..ed30bd91 100644 --- a/tests/app/models/TestModel.php +++ b/tests/app/classes/TestModel.php @@ -1,11 +1,9 @@ Date: Wed, 24 Mar 2021 22:00:08 +0100 Subject: [PATCH 4/5] use Nano\Tests\TestModel --- tests/ModelTest.php | 1 + tests/app/classes/TestModel.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 4c4fcc46..cf14de39 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -1,6 +1,7 @@ Date: Wed, 24 Mar 2021 22:01:03 +0100 Subject: [PATCH 5/5] use Nano\TestApp\TestModel --- tests/ModelTest.php | 2 +- tests/app/classes/TestModel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ModelTest.php b/tests/ModelTest.php index cf14de39..cab56d6f 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -1,7 +1,7 @@