Skip to content

Commit

Permalink
Merge pull request #25 from elecena/test-models
Browse files Browse the repository at this point in the history
Test models
  • Loading branch information
macbre committed Mar 24, 2021
2 parents 36e413c + eefee9f commit ee5ec9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
22 changes: 15 additions & 7 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<?php

use Nano\NanoBaseTest;
use Nano\TestApp\TestModel;

/**
* Set of unit tests for Model class
*
* @covers TestModel
*/
class ModelTest extends \Nano\NanoBaseTest
class ModelTest extends NanoBaseTest
{
/**
* @var TestModel
*/
private $model;

public function setUp(): void
{
$dir = realpath(dirname(__FILE__) . '/app');
$this->app = Nano::app($dir);
parent::setUp();
$this->model = new TestModel();
}

public function testGetMagic()
{
$model = $this->app->factory('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());
}
}
14 changes: 7 additions & 7 deletions tests/app/classes/TestModel.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

namespace Nano\TestApp;

/**
* An example model
*
* @method array getFoo
*/
class TestModel extends Model
class TestModel extends \Model
{

/**
* @param NanoApp $app
*/
public function __construct(NanoApp $app)
public function __construct()
{
parent::__construct($app);
parent::__construct();

$this->data = [
'foo' => 'bar',
Expand Down

0 comments on commit ee5ec9a

Please sign in to comment.