diff --git a/tests/AdminLoginTest.php b/tests/AdminLoginTest.php index b0c27b4af..d9b745df3 100644 --- a/tests/AdminLoginTest.php +++ b/tests/AdminLoginTest.php @@ -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'); @@ -23,7 +23,6 @@ public function testGetLogin() */ public function testPostLogin() { - $this->assertTrue(true); $this->visit('/admin/login') ->type('admin@admin.com', 'email') ->type('admin123', 'password') diff --git a/tests/AdminRoleTest.php b/tests/AdminRoleTest.php new file mode 100644 index 000000000..663c1b642 --- /dev/null +++ b/tests/AdminRoleTest.php @@ -0,0 +1,44 @@ +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') + ; + } + + + +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 07bf83c2e..d4c92391c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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 { /** @@ -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' => 'admin@admin.com', '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);