-
-
Notifications
You must be signed in to change notification settings - Fork 288
[Fix] Added padding to percentage string #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nunomaduro
merged 5 commits into
nunomaduro:master
from
olivernybroe:pad_percentage_string
May 15, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6226456
Fix: Added padding to percentage string
olivernybroe c4042da
Fix: Fix refactoring to constant errors on string inline variables
olivernybroe 70f8fc7
Tests: Added phpunit to the composer test method
olivernybroe 84dc37f
Test: Add color styling to phpunit command
olivernybroe eb9a94d
Refactor: Change getPercentageAsString to private and test after this
olivernybroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Application\Console; | ||
|
||
use NunoMaduro\PhpInsights\Application\Console\Style; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @covers \NunoMaduro\PhpInsights\Application\Console\Style | ||
*/ | ||
final class StyleTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function stringHasCorrectLengthWhenOneDigitValue() : void | ||
{ | ||
$percentageString = $this->invokeStaticMethod(Style::class, 'getPercentageAsString', 1); | ||
|
||
$this->assertEquals(5, strlen($percentageString)); | ||
} | ||
|
||
/** @test */ | ||
public function stringHasCorrectLengthWhenTWODigitValue() : void | ||
{ | ||
$percentageString = $this->invokeStaticMethod(Style::class, 'getPercentageAsString', 10); | ||
|
||
$this->assertEquals(5, strlen($percentageString)); | ||
} | ||
|
||
/** @test */ | ||
public function stringHasCorrectLengthWhenThreeDigitValue() : void | ||
{ | ||
$percentageString = $this->invokeStaticMethod(Style::class, 'getPercentageAsString', 100); | ||
|
||
$this->assertEquals(5, strlen($percentageString)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
use ReflectionClass; | ||
use ReflectionException; | ||
|
||
abstract class TestCase extends BaseTestCase | ||
{ | ||
/** | ||
* Call protected/private method of a class. | ||
* | ||
* @param string $class Instantiated object that we will run method on. | ||
* @param string $methodName Method name to call. | ||
* @param array $parameters Array of parameters to pass into method. | ||
* | ||
* @return mixed Method result. | ||
* @throws ReflectionException | ||
*/ | ||
public function invokeStaticMethod(string $class, string $methodName, ...$parameters) | ||
{ | ||
$reflection = new ReflectionClass($class); | ||
$method = $reflection->getMethod($methodName); | ||
$method->setAccessible(true); | ||
|
||
return $method->invokeArgs(null, $parameters); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.