create() public static method

public static create ( $class, $data = [] )
Ejemplo n.º 1
0
 public function test_Should_DeleteExistingServer()
 {
     $arrangedServer = Factory::create('App\\Models\\Server', ['name' => 'Server 1', 'description' => '', 'body' => '']);
     $serverRepository = new EloquentServer(new App\Models\Server());
     $serverRepository->delete($arrangedServer->id);
     $server = new App\Models\Server();
     $deletedServer = $server->find($arrangedServer->id);
     $this->assertNull($deletedServer);
 }
Ejemplo n.º 2
0
 public function test_Should_DeleteExistingRole()
 {
     $arrangedRole = Factory::create('Kodeine\\Acl\\Models\\Eloquent\\Role', ['name' => 'Role 1', 'slug' => 'role_1', 'description' => '']);
     $serverRepository = new EloquentRole(new Kodeine\Acl\Models\Eloquent\Role());
     $serverRepository->delete($arrangedRole->id);
     $server = new Kodeine\Acl\Models\Eloquent\Role();
     $deletedRole = $server->find($arrangedRole->id);
     $this->assertNull($deletedRole);
 }
Ejemplo n.º 3
0
 public function test_Should_DeleteExistingRecipe()
 {
     $arrangedRecipe = Factory::create('App\\Models\\Recipe', ['name' => 'Recipe 1', 'description' => '', 'body' => '']);
     $recipeRepository = new EloquentRecipe(new App\Models\Recipe());
     $recipeRepository->delete($arrangedRecipe->id);
     $recipe = new App\Models\Recipe();
     $deletedRecipe = $recipe->find($arrangedRecipe->id);
     $this->assertNull($deletedRecipe);
 }
 public function test_Should_PassToValidate_When_NameFieldAndRecipeIdFieldAndServerIdFieldAndRepositoryFieldAndStageFieldAreValid()
 {
     Factory::create('App\\Models\\Recipe', ['name' => 'Recipe 1', 'description' => '', 'body' => '']);
     Factory::create('App\\Models\\Server', ['name' => 'Server 1', 'description' => '', 'body' => '']);
     $input = ['name' => 'Project 1', 'recipe_id' => [1], 'server_id' => 1, 'repository' => 'http://example.com', 'stage' => 'staging'];
     $form = new ProjectFormLaravelValidator($this->app['validator']);
     $result = $form->with($input)->passes();
     $errors = $form->errors();
     $this->assertTrue($result, 'Expected validation to succeed.');
     $this->assertEmpty($errors);
 }
 public function test_Should_PassToValidate_When_ProjectIdFieldAndTaskFieldAndUserIdFieldAreValid()
 {
     $arrangedServer = Factory::create('App\\Models\\Server', ['name' => 'Server 1', 'description' => '', 'body' => '']);
     Factory::create('App\\Models\\Project', ['name' => 'Project 1', 'server_id' => $arrangedServer->id, 'stage' => 'staging']);
     Factory::create('App\\Models\\User', ['email' => '*****@*****.**', 'password' => '0123456789', 'api_token' => '0123456789']);
     $input = ['project_id' => 1, 'task' => 'deploy', 'user_id' => 1];
     $form = new DeploymentFormLaravelValidator($this->app['validator']);
     $result = $form->with($input)->passes();
     $errors = $form->errors();
     $this->assertTrue($result, 'Expected validation to succeed.');
     $this->assertEmpty($errors);
 }
Ejemplo n.º 6
0
 public function test_Should_GetDeploymentsWhereNumberBefore()
 {
     $arrangedServer = Factory::create('App\\Models\\Server');
     $arrangedProject = Factory::create('App\\Models\\Project', ['server_id' => $arrangedServer->id]);
     $arrangedDeployments1 = Factory::create('App\\Models\\Deployment', ['project_id' => $arrangedProject->id, 'number' => 1]);
     $arrangedDeployments2 = Factory::create('App\\Models\\Deployment', ['project_id' => $arrangedProject->id, 'number' => 2]);
     $arrangedDeployments3 = Factory::create('App\\Models\\Deployment', ['project_id' => $arrangedProject->id, 'number' => 3]);
     $arrangedDeployments4 = Factory::create('App\\Models\\Deployment', ['project_id' => $arrangedProject->id, 'number' => 4]);
     $foundDeployments = $arrangedProject->getDeploymentsWhereNumberBefore(3);
     $this->assertEquals($arrangedDeployments2, $foundDeployments[0]);
     $this->assertEquals($arrangedDeployments1, $foundDeployments[1]);
 }
Ejemplo n.º 7
0
 public function test_Should_DeleteExistingProject()
 {
     $arrangedRecipe = Factory::create('App\\Models\\Recipe', ['name' => 'Recipe 1', 'description' => '', 'body' => '']);
     $arrangedServer = Factory::create('App\\Models\\Server', ['name' => 'Recipe 1', 'description' => '', 'body' => '']);
     $arrangedProject = Factory::create('App\\Models\\Project', ['name' => 'Project 1', 'server_id' => $arrangedServer->id, 'stage' => 'staging']);
     $arrangedProject->recipes()->sync([$arrangedRecipe->id => ['recipe_order' => 1]]);
     $projectRepository = new EloquentProject(new App\Models\Project(), new App\Models\MaxDeployment());
     $projectRepository->delete($arrangedProject->id);
     $project = new App\Models\Project();
     $deletedProject = $project->find($arrangedProject->id);
     $this->assertNull($deletedProject);
     $updatedProjectRecipes = $arrangedProject->recipes;
     $this->assertEmpty($updatedProjectRecipes);
 }
Ejemplo n.º 8
0
 public function test_Should_PassToValidate_When_EmailFieldIsNotUniqueAndIdFieldIsSpecified()
 {
     $arrangedUser = Factory::create('App\\Models\\User', ['email' => '*****@*****.**']);
     $input = ['id' => $arrangedUser->id, 'email' => '*****@*****.**'];
     $form = new UserFormLaravelValidator($this->app['validator']);
     $result = $form->with($input)->passes();
     $errors = $form->errors();
     $this->assertTrue($result, 'Expected validation to succeed.');
     $this->assertEmpty($errors);
 }
Ejemplo n.º 9
0
 public function test_Should_DeleteExistingUser()
 {
     $arrangedUser = Factory::create('App\\Models\\User', ['name' => 'User 1', 'email' => '*****@*****.**', 'password' => '12345678', 'api_token' => '12345678']);
     $userRepository = new EloquentUser(new App\Models\User());
     $userRepository->delete($arrangedUser->id);
     $user = new App\Models\User();
     $deletedUser = $user->find($arrangedUser->id);
     $this->assertNull($deletedUser);
 }