mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
Improvements to the SystemNodeProviderTest class (#211)
* Changes location of providers in the SystemNodeProviderTest They are now grouped at the bottom of the class. * Adds logic to SystemNodeProviderTest. * Changes call to `file_get_contents` SystemNodeProvider so it can be mocked. * Changes SystemNodeProviderTest so native PHP functions are mocked instead of the class under test. * Changes SystemNodeProviderTest so "\n" is used instead of PHP_EOL As the (input or output) of the tests is not system dependant it does not make sense to use PHP_EOL. All of these instance have been replaced for the sake of readability and stating intent more clearly. * Adds dataprovider to SystemNodeProvider main test for input variations. * Adds OS to SystemNodeProviderTest dataprovider for Linux fail scenario. * Adds test for SystemNodeProvider to ensure invalid values are not accepted. * Changes names of dataproviders in SystemNodeProviderTest for consistency. * Changes SystemNodeProviderTest by grouping dataproviders together. * Changes method in SystemNodeProviderTest to use the provided mock functions. * Fixes PSR-2 coding conventions in SystemNodeProviderTest. * Minor change to SystemNodeProviderTest based on review.
This commit is contained in:
@@ -88,17 +88,16 @@ class SystemNodeProvider implements NodeProviderInterface
|
||||
{
|
||||
$mac = false;
|
||||
|
||||
if (strtoupper(php_uname('s')) === "LINUX") {
|
||||
if (strtoupper(php_uname('s')) === 'LINUX') {
|
||||
$addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT);
|
||||
|
||||
if (empty($addressPaths)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$macs = array_map(
|
||||
'file_get_contents',
|
||||
$addressPaths
|
||||
);
|
||||
array_walk($addressPaths, function ($addressPath) use (&$macs) {
|
||||
$macs[] = file_get_contents($addressPath);
|
||||
});
|
||||
|
||||
$macs = array_map('trim', $macs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user