AbstractResourceHolderTest.php (886B)
1 <?php 2 3 namespace Ssh; 4 5 /** 6 * @covers \Ssh\AbstractResourceHolder 7 */ 8 class AbstractResourceHolderTest extends \PHPUnit_Framework_TestCase 9 { 10 public function testResourceIsCreatedIfItDoesNotExist() 11 { 12 $holder = $this->getMockForAbstractClass('Ssh\AbstractResourceHolder'); 13 $holder->expects($this->once()) 14 ->method('createResource'); 15 16 $holder->getResource(); 17 } 18 19 public function testResourceIsCreatedOnlyOne() 20 { 21 $holder = $this->getMockForAbstractClass('Ssh\AbstractResourceHolder'); 22 $holder->expects($this->never()) 23 ->method('createResource'); 24 25 $resource = tmpfile(); 26 27 $property = new \ReflectionProperty($holder, 'resource'); 28 $property->setAccessible(true); 29 $property->setValue($holder, $resource); 30 31 $this->assertEquals($resource, $holder->getResource()); 32 } 33 }