Skip to content

Commit

Permalink
Standardized result key names
Browse files Browse the repository at this point in the history
Changed steps_completed to steps_complete to standardize its word usage among the other keys.
  • Loading branch information
mtownsend5512 committed Sep 21, 2020
1 parent 400bf7b commit 8d8d808
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $progress = (new Progress(
"total_steps" => 1
"percentage_complete" => 100.0
"percentage_incomplete" => 0.0
"steps_completed" => 1
"steps_complete" => 1
"steps_incomplete" => 0
"complete_step_names" => [
0 => "Age"
Expand Down
2 changes: 1 addition & 1 deletion src/Progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function evaluate(): array
'total_steps' => $this->countSteps(),
'percentage_complete' => $this->percentageComplete(),
'percentage_incomplete' => max(100 - $this->percentageComplete(), 0),
'steps_completed' => $this->countStepsPassed(),
'steps_complete' => $this->countStepsPassed(),
'steps_incomplete' => $this->countSteps() - $this->countStepsPassed(),
'complete_step_names' => $this->passedStepNames(),
'incomplete_step_names' => $this->failedStepNames()
Expand Down
10 changes: 5 additions & 5 deletions tests/ProgressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function step_fails()
public function progress_can_receive_single_step()
{
$result = new Progress((new Step(31, 'Age'))->integer());
$this->assertEquals($result->get()['steps_completed'], 1);
$this->assertEquals($result->get()['steps_complete'], 1);
}

/** @test */
Expand All @@ -35,7 +35,7 @@ public function progress_can_receive_multiple_steps()
(new Step(31, 'Age'))->integer(),
(new Step('John Smith', 'Name'))->string()->notEmpty()
);
$this->assertEquals($result->get()['steps_completed'], 2);
$this->assertEquals($result->get()['steps_complete'], 2);
}

/** @test */
Expand All @@ -47,7 +47,7 @@ public function progress_can_receive_array_of_steps()
(new Step(true, 'Premier Member'))->boolean(),
];
$result = new Progress($steps);
$this->assertEquals($result->get()['steps_completed'], 3);
$this->assertEquals($result->get()['steps_complete'], 3);
}

/** @test */
Expand Down Expand Up @@ -82,7 +82,7 @@ public function can_retrieve_result_key_from_magic_property()
$progress = new Progress($steps);
$progress->get();

$this->assertEquals($progress->steps_completed, 3);
$this->assertEquals($progress->steps_complete, 3);
}

/** @test */
Expand All @@ -104,7 +104,7 @@ public function progress_outputs_json()
(new Step(null, 'List Your First Item For Sale'))->notEmpty()->integer(),
];
$result = (new Progress($steps))->toJson();
$json = '{"total_steps":5,"percentage_complete":60,"percentage_incomplete":40,"steps_completed":3,"steps_incomplete":2,"complete_step_names":["Age","Confirmed Email","Connect Your Facebook"],"incomplete_step_names":{"3":"Connect Your PayPal","4":"List Your First Item For Sale"}}';
$json = '{"total_steps":5,"percentage_complete":60,"percentage_incomplete":40,"steps_complete":3,"steps_incomplete":2,"complete_step_names":["Age","Confirmed Email","Connect Your Facebook"],"incomplete_step_names":{"3":"Connect Your PayPal","4":"List Your First Item For Sale"}}';

$this->assertEquals($result, $json);
}
Expand Down

0 comments on commit 8d8d808

Please sign in to comment.