Skip to content

Commit

Permalink
adding more unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
indpurvesh committed Nov 17, 2016
1 parent f5aae62 commit c6dd0a6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tests/AdminLoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AdminLoginTest extends TestCase
*/
public function testGetLogin()
{
$this->assertTrue(true);

$this->visit($this->baseUrl.'/admin/login')
->seePageIs($this->baseUrl.'/admin/login')
->see('Mage2 Admin Login');
Expand All @@ -23,7 +23,6 @@ public function testGetLogin()
*/
public function testPostLogin()
{
$this->assertTrue(true);
$this->visit('/admin/login')
->type('[email protected]', 'email')
->type('admin123', 'password')
Expand Down
44 changes: 44 additions & 0 deletions tests/AdminRoleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class AdminRoleTest extends TestCase {

/**
* A basic test example.
*
* @return void
*/
public function testAdminRoleList() {
$this->adminUserLogin();
$this->visit('/admin/role')
->see('Role List')
->see('Administrator')
;
}
/**
* A basic test example.
*
* @return void
*/
public function testAdminRoleCreate() {
$this->adminUserLogin();
$this->visit('/admin/role/create')
->see('Create Role')
->type('Editor','name')
->type('editor description','description')
//->check('permissions[admin.category.index]')
//->check('permissions[admin.category.create,admin.category.store]')
//->check('permissions[admin.category.edit,admin.category.update]')
//->check('permissions[admin.category.destroy]')
->press('Create Role')
->seePageIs('/admin/role')
->see('Editor')
;
}



}
8 changes: 6 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Mage2\Configuration\Models\Configuration;
use Mage2\Install\Models\Website;
use Mage2\User\Models\User;

use Mage2\User\Models\Role;
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**
Expand Down Expand Up @@ -130,13 +130,17 @@ private function _createFrontUser()

private function setupAdminUserAndWebsite()
{
$role = Role::create(['name' => 'Administrator',
'description' => 'administrator role'
]);

AdminUser::create([
'first_name' => 'test User',
'last_name' => 'test User',
'email' => '[email protected]',
'password' => bcrypt('admin123'),
'is_super_admin' => 1,
'role_id' => 1, // @todo change this one??
'role_id' => $role->id, // @todo change this one??
]);

$host = str_replace('http://', '', $this->baseUrl);
Expand Down

0 comments on commit c6dd0a6

Please sign in to comment.