diff --git a/tests/Provider/Node/SystemNodeProviderTest.php b/tests/Provider/Node/SystemNodeProviderTest.php index fa9e98e..a425d83 100644 --- a/tests/Provider/Node/SystemNodeProviderTest.php +++ b/tests/Provider/Node/SystemNodeProviderTest.php @@ -15,9 +15,13 @@ class SystemNodeProviderTest extends TestCase public function testGetNodeReturnsSystemNodeFromMacAddress() { $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $provider->expects($this->once()) ->method('getIfconfig') ->willReturn(PHP_EOL . 'AA-BB-CC-DD-EE-FF' . PHP_EOL); @@ -50,11 +54,15 @@ class SystemNodeProviderTest extends TestCase { //Using a stub to provide data for the protected method that gets the node $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); $provider->method('getIfconfig') ->willReturn(PHP_EOL . $formatted . PHP_EOL); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $node = $provider->getNode(); $this->assertEquals($expected, $node); } @@ -67,13 +75,17 @@ class SystemNodeProviderTest extends TestCase { //Using a stub to provide data for the protected method that gets the node $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); $provider->method('getIfconfig') ->willReturn(PHP_EOL . 'AA-BB-CC-DD-EE-FF' . PHP_EOL . '00-11-22-33-44-55' . PHP_EOL . 'FF-11-EE-22-DD-33' . PHP_EOL); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $node = $provider->getNode(); $this->assertEquals('AABBCCDDEEFF', $node); } @@ -85,13 +97,17 @@ class SystemNodeProviderTest extends TestCase public function testGetNodeReturnsFalseWhenNodeIsNotFound() { $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); $provider->expects($this->once()) ->method('getIfconfig') ->willReturn('some string that does not match the mac address'); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $node = $provider->getNode(); $this->assertFalse($node); } @@ -103,13 +119,17 @@ class SystemNodeProviderTest extends TestCase public function testGetNodeWillNotExecuteSystemCallIfFailedFirstTime() { $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); $provider->expects($this->once()) ->method('getIfconfig') ->willReturn('some string that does not match the mac address'); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $provider->getNode(); $provider->getNode(); } @@ -137,7 +157,14 @@ class SystemNodeProviderTest extends TestCase AspectMock::func('Ramsey\Uuid\Provider\Node', 'php_uname', $os); $passthru = AspectMock::func('Ramsey\Uuid\Provider\Node', 'passthru', 'whatever'); - $provider = new SystemNodeProvider(); + $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') + ->setMethods(['getsysfs']) + ->getMock(); + + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); + $provider->getNode(); $passthru->verifyInvokedOnce([$command]); } @@ -168,11 +195,14 @@ class SystemNodeProviderTest extends TestCase { //Using a mock to verify the provider only gets the node from ifconfig one time $provider = $this->getMockBuilder('Ramsey\Uuid\Provider\Node\SystemNodeProvider') - ->setMethods(['getIfconfig']) + ->setMethods(['getIfconfig','getsysfs']) ->getMock(); $provider->expects($this->once()) ->method('getIfconfig') ->willReturn(PHP_EOL . 'AA-BB-CC-DD-EE-FF' . PHP_EOL); + $provider->expects($this->once()) + ->method('getsysfs') + ->willReturn(false); $provider->getNode(); $provider->getNode(); }