public function testDeleteRole() { $role = Woodling::saved('Role'); $response = $this->call('DELETE', '/api/roles/' . $role->id); $data = $this->assertResponse($response); $id = DB::table('roles')->where('id', $role->id)->pluck('id'); $this->assertEmpty($id); }
public function testAuthedUpdateOwnUserImageWithExistingImageSetToEmpty() { $user = $this->helperCreateUserAndLogin(); $upload = Woodling::saved('Upload', ['user_id' => $user->id]); $user->image = $upload->id; $user->updateUniques(); $response = $this->call('PUT', '/api/users/' . $user->id, ['image' => null]); $data = $this->assertResponse($response); $this->assertEmpty($data->image); }
public function testLogoutCurrentUserReturnsGuestUserObject() { $user = Woodling::saved('User'); $response = $this->call('POST', '/api/auth', ['username' => $user->email, 'password' => 'password']); $response = $this->call('DELETE', '/api/auth/me'); $data = $this->assertResponse($response); $response = $this->call('GET', '/api/auth/me'); $data = $this->assertResponse($response); $this->assertEmpty($data->id); $this->assertEquals('guest', $data->username); }
<?php use Woodling\Woodling; Woodling::seed('RoleAdmin', array('class' => 'Role', 'do' => function ($blueprint) { $blueprint->id = 1; $blueprint->name = 'admin'; })); Woodling::seed('RoleComment', array('class' => 'Role', 'do' => function ($blueprint) { $blueprint->id = 1; $blueprint->name = 'comment'; }));
public function helperCreateUserAndLogin($roleName = null) { // If role doesn't exist, create it if ($roleName && !($roleId = DB::table('roles')->where('name', $roleName)->pluck('id'))) { $role = new Role(); $role->name = $roleName; $role->save(); $roleId = $role->id; } // Create test user $user = Woodling::saved('User'); if ($roleName) { $user->roles()->sync([$roleId]); } Auth::login($user); return $user; }
public function testStaticSavedListWithOverrides() { $name = 'stdClass'; $count = 3; $overrides = array('name' => 'Mindaugas Bujanauskas'); $returnValue = new $name(); $coreMock = $this->getMock('Woodling\\Core', array('savedList')); $coreMock->expects($this->once())->method('savedList')->with($this->equalTo($name), $this->equalTo($count), $this->equalTo($overrides))->will($this->returnValue($returnValue)); Woodling::core($coreMock); $list = Woodling::savedList($name, $count, $overrides); $this->assertEquals($returnValue, $list); }
public function testAdminDeleteUserCleansAssignedRoles() { $admin = $this->helperCreateUserAndLogin('admin'); $user = Woodling::saved('User'); $roles = Woodling::savedList('Role', 3); $this->call('PUT', '/api/users/' . $user->id, ['roles' => $roles]); $response = $this->call('DELETE', '/api/users/' . $user->id); $assigned = DB::table('assigned_roles')->where('user_id', $user->id)->get(); $this->assertEquals(0, count($assigned)); }
public function testIsConfirmedByEmailFail() { $user = Woodling::retrieve('UserAdmin'); $this->assertNotEquals($user->isConfirmed(array('email' => '*****@*****.**')), true); }
<?php use Woodling\Woodling; Woodling::seed('Role', function ($blueprint) { $blueprint->sequence('name', function ($i) { return 'role_' . $i; }); });
<?php use Woodling\Woodling; use Carbon\Carbon; Woodling::seed('Post', array('class' => 'Post', 'do' => function ($blueprint) { $blueprint->slug = 'in-iisque-similique-reprimique-eum'; $blueprint->created_at = Carbon::now(); $blueprint->updated_at = Carbon::now(); })); Woodling::seed('PostOld', array('class' => 'Post', 'do' => function ($blueprint) { $blueprint->slug = 'in-iisque-similique-reprimique-eum'; $blueprint->created_at = Carbon::now()->subWeeks(2); $blueprint->updated_at = Carbon::now()->subWeeks(2); }));
public function testUrl() { $post = Woodling::retrieve('Post'); $this->assertGreaterThan(0, strpos($post->url(), 'in-iisque-similique-reprimique-eum')); }
public function testResetPasswordInvalidPassword() { $user = Woodling::saved('User'); $response = $this->call('POST', '/api/users/forgot', ['email' => $user->email]); $data = $this->assertResponse($response); $token = DB::table('password_reminders')->where('email', $user->email)->pluck('token'); $response = $this->call('POST', '/api/users/reset', ['token' => $token, 'password' => 'newpassword', 'password_confirmation' => 'foobar']); $data = $this->assertResponse($response, 400); }
public function testProducts() { $user = Woodling::retrieve('Game 1'); $this->assertInstanceOf('Illuminate\\Database\\Eloquent\\Relations\\HasMany', $user->products()); $this->assertEquals($user->products()->first(), null); }
<?php use Woodling\Woodling; Woodling::seed('Upload', function ($blueprint) { $blueprint->path = 'uploads'; $blueprint->sequence('filename', function ($i) { return 'test-upload-' . $i . '.jpg'; }); });
<?php use Woodling\Woodling; Woodling::seed('manage_posts', array('class' => 'Permission', 'do' => function ($blueprint) { $blueprint->id = 1; $blueprint->name = 'manage_posts'; $blueprint->display_name = 'manage posts'; })); Woodling::seed('manage_pages', array('class' => 'Permission', 'do' => function ($blueprint) { $blueprint->id = 2; $blueprint->name = 'manage_pages'; $blueprint->display_name = 'manage pages'; })); Woodling::seed('manage_users', array('class' => 'Permission', 'do' => function ($blueprint) { $blueprint->id = 3; $blueprint->name = 'manage_users'; $blueprint->display_name = 'manage users'; })); Woodling::seed('post_comment', array('class' => 'Permission', 'do' => function ($blueprint) { $blueprint->id = 4; $blueprint->name = 'post_comment'; $blueprint->display_name = 'post_comment'; }));
<?php use Woodling\Woodling; use J20\Uuid; use Carbon\Carbon; Woodling::seed('UserAdmin', array('class' => 'User', 'do' => function ($blueprint) { $blueprint->username = '******'; $blueprint->email = '*****@*****.**'; $blueprint->confirmation_code = md5(uniqid(mt_rand(), true)); $blueprint->confirmed = 1; $blueprint->created = Carbon::now(); $blueprint->updated = Carbon::now()->addMonths(2); $blueprint->role = function () { return Woodling::retrieve('RoleAdmin'); }; })); Woodling::seed('UserUser', array('class' => 'User', 'do' => function ($blueprint) { $blueprint->username = '******'; $blueprint->email = '*****@*****.**'; $blueprint->confirmation_code = md5(uniqid(mt_rand(), true)); $blueprint->confirmed = 1; $blueprint->created = Carbon::now(); $blueprint->updated = Carbon::now()->addMonths(2); $blueprint->role = function () { return Woodling::retrieve('RoleComment'); }; }));
public function testUpdatedAtFullDisplay() { $comment = Woodling::retrieve('CommentOld'); $this->assertEquals(0, strpos($comment->updated_at(), 'ago')); }
<?php use Woodling\Woodling; use J20\Uuid; use Carbon\Carbon; Woodling::seed('Game 1', array('class' => 'Game', 'do' => function ($blueprint) { $blueprint->title = 'Mario Kart 8'; $blueprint->image = 'assets/images/portfolio/vign4.jpg'; $blueprint->slug = 'game-1'; $blueprint->content = "Hola \n supu"; $blueprint->meta_title = 'Game 1'; $blueprint->meta_description = 'Game 1'; $blueprint->meta_keywords = 'Game 1, console, game'; })); Woodling::seed('Game 2', array('class' => 'Game', 'do' => function ($blueprint) { $blueprint->title = 'Game 2'; $blueprint->image = 'assets/images/portfolio/game2.jpg'; $blueprint->slug = 'game-2'; $blueprint->meta_title = "Hola \n supu"; $blueprint->content = 'body 2'; $blueprint->meta_description = 'Game 2'; $blueprint->meta_keywords = 'Game 2, console, game'; }));
public function testGetByUsernameFail() { $user = Woodling::retrieve('UserAdmin'); $this->assertEquals($user->getUserByUsername('non-user'), false); }
<?php use Woodling\Woodling; Woodling::seed('User', function ($blueprint) { $blueprint->sequence('email', function ($i) { return 'testing_' . $i . '@mail.net'; }); $blueprint->sequence('username', function ($i) { return 'test_' . $i; }); $blueprint->password = '******'; $blueprint->password_confirmation = 'password'; $blueprint->confirmation_code = rand(100, 1000); $blueprint->confirmed = 1; $blueprint->status = 1; });
<?php use Woodling\Woodling; use Carbon\Carbon; Woodling::seed('Comment', array('class' => 'Comment', 'do' => function ($blueprint) { $blueprint->created_at = Carbon::now(); $blueprint->updated_at = Carbon::now(); })); Woodling::seed('CommentOld', array('class' => 'Comment', 'do' => function ($blueprint) { $blueprint->created_at = Carbon::now()->subWeeks(2); $blueprint->updated_at = Carbon::now()->subWeeks(2); }));
public function testName() { $permission = Woodling::retrieve('manage_posts'); $this->assertEquals($permission->name, 'manage_posts'); $this->assertEquals($permission->display_name, 'manage posts'); }
public function testName() { $role = Woodling::retrieve('RoleAdmin'); $this->assertEquals($role->name, 'admin'); }