/** * @test */ public function renderWithSubpackageIgnoresExcludedFile() { $includedFile = $this->getMock('File', array('getPathname')); $includedFile->expects($this->any())->method('getPathname')->will($this->returnValue('resource://MyPackage/Public/MySubpackage/JavaScript/Foo.js')); $excludedFile = $this->getMock('File', array('getPathname')); $excludedFile->expects($this->any())->method('getPathname')->will($this->returnValue('resource://MyPackage/Public/MySubpackage/JavaScript/Bar.js')); $files = array($includedFile, $excludedFile); $this->viewHelper->expects($this->atLeastOnce())->method('iterateDirectoryRecursively')->with('resource://MyPackage/Public/MySubpackage/JavaScript/')->will($this->returnValue($files)); $output = $this->viewHelper->render('.*\\.js', 'Bar.*', null, 'MySubpackage'); $this->assertEquals('<script src="StaticResourceUri/Packages/MyPackage/MySubpackage/JavaScript/Foo.js"></script>' . chr(10), $output); }
/** * @test */ public function renderWithSubpackageIgnoresExcludedFile() { if (PHP_VERSION_ID < 50609) { $this->markTestSkipped('Test fails with PHP 5.5 and/or PhpUnit 4.8 while building mocks.'); } $includedFile = $this->getMockBuilder(\SplFileInfo::class)->disableOriginalConstructor()->setMethods(array('getPathname'))->getMock(); $includedFile->expects($this->any())->method('getPathname')->will($this->returnValue('resource://MyPackage/Public/MySubpackage/JavaScript/Foo.js')); $excludedFile = $this->getMockBuilder(\SplFileInfo::class)->disableOriginalConstructor()->setMethods(array('getPathname'))->getMock(); $excludedFile->expects($this->any())->method('getPathname')->will($this->returnValue('resource://MyPackage/Public/MySubpackage/JavaScript/Bar.js')); $files = array($includedFile, $excludedFile); $this->viewHelper->expects($this->atLeastOnce())->method('iterateDirectoryRecursively')->with('resource://MyPackage/Public/MySubpackage/JavaScript/')->will($this->returnValue($files)); $output = $this->viewHelper->render('.*\\.js', 'Bar.*', null, 'MySubpackage'); $this->assertEquals('<script src="StaticResourceUri/Packages/MyPackage/MySubpackage/JavaScript/Foo.js"></script>' . chr(10), $output); }