-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
200 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Rougin\Credo; | ||
|
||
use Rougin\SparkPlug\Instance; | ||
use Rougin\Credo\Credo; | ||
|
||
/** | ||
* Credo Trait Test | ||
* | ||
* @package Credo | ||
* @author Rougin Royce Gutib <rougingutib@gmail.com> | ||
*/ | ||
class CredoTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \CI_Controller | ||
*/ | ||
protected $ci; | ||
|
||
/** | ||
* @var integer | ||
*/ | ||
protected $rows = 10; | ||
|
||
/** | ||
* Sets up the Codeigniter application. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$path = (string) __DIR__ . '/Weblog'; | ||
|
||
$this->ci = Instance::create($path); | ||
|
||
$this->ci->load->database(); | ||
|
||
$this->ci->load->model('post'); | ||
} | ||
|
||
/** | ||
* Tests CredoTrait::find. | ||
* | ||
* @return void | ||
*/ | ||
public function testFindMethod() | ||
{ | ||
list($id, $expected) = array(2, 'viG iJOzO'); | ||
|
||
$post = $this->ci->post->find((integer) $id); | ||
|
||
$result = (string) $post->get_subject(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* Tests CredoTrait::findBy. | ||
* | ||
* @return void | ||
*/ | ||
public function testFindByMethod() | ||
{ | ||
$this->assertCount($this->rows, $this->ci->post->findBy()); | ||
} | ||
|
||
/** | ||
* Tests CredoTrait::get. | ||
* | ||
* @return void | ||
*/ | ||
public function testGetMethod() | ||
{ | ||
$this->assertCount($this->rows, $this->ci->post->get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Rougin\Credo; | ||
|
||
use Rougin\SparkPlug\Instance; | ||
|
||
/** | ||
* Paginate Trait Test | ||
* | ||
* @package Credo | ||
* @author Rougin Royce Gutib <rougingutib@gmail.com> | ||
*/ | ||
class PaginateTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \CI_Controller | ||
*/ | ||
protected $ci; | ||
|
||
/** | ||
* Sets up the Codeigniter application. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$path = (string) __DIR__ . '/Weblog'; | ||
|
||
$this->ci = Instance::create($path); | ||
|
||
$this->ci->load->model('post'); | ||
} | ||
|
||
/** | ||
* Tests PaginateTrait::paginate. | ||
* | ||
* @return void | ||
*/ | ||
public function testPaginateMethod() | ||
{ | ||
$expected = (integer) 10; | ||
|
||
$config = array('page_query_string' => true); | ||
|
||
$config['use_page_numbers'] = true; | ||
|
||
$_GET['per_page'] = (integer) 3; | ||
|
||
$post = new \Post(array('user_id' => 1)); | ||
|
||
list($result) = $post->paginate(5, 20, $config); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Rougin\Credo; | ||
|
||
use Rougin\SparkPlug\Instance; | ||
|
||
/** | ||
* Validate Trait Test | ||
* | ||
* @package Credo | ||
* @author Rougin Royce Gutib <rougingutib@gmail.com> | ||
*/ | ||
class ValidateTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \CI_Controller | ||
*/ | ||
protected $ci; | ||
|
||
/** | ||
* Sets up the Codeigniter application. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$path = (string) __DIR__ . '/Weblog'; | ||
|
||
$this->ci = Instance::create($path); | ||
|
||
$this->ci->load->model('post'); | ||
} | ||
|
||
/** | ||
* Tests ValidateTrait::validate. | ||
* | ||
* @return void | ||
*/ | ||
public function testValidateMethod() | ||
{ | ||
$expected = array('subject' => 'The Subject field is required.'); | ||
|
||
$post = new \Post(array()); | ||
|
||
$post->validate(array('message' => 'test')); | ||
|
||
$result = (array) $post->errors(); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
|
||
use Rougin\Credo\EntityRepository; | ||
use Rougin\Credo\Repository; | ||
|
||
class Post_repository extends EntityRepository | ||
class Post_repository extends Repository | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
|
||
use Rougin\Credo\EntityRepository; | ||
use Rougin\Credo\Repository; | ||
|
||
class User_repository extends EntityRepository | ||
class User_repository extends Repository | ||
{ | ||
} |