Skip to content

Commit

Permalink
Merge branch '4.2-dev' into fix_fatal_error_webauthn
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 committed Jun 26, 2022
2 parents a5042e1 + 681c8c0 commit ac43036
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 110 deletions.
5 changes: 1 addition & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ steps:
- name: php81-unit
depends_on: [ phpcs ]
image: joomlaprojects/docker-images:php8.1
failure: ignore
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Unit
Expand Down Expand Up @@ -88,7 +87,6 @@ steps:
- name: php80-integration
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.0
failure: ignore
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration
Expand Down Expand Up @@ -131,7 +129,6 @@ steps:
- name: php80-integration-pgsql
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.0
failure: ignore
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit-pgsql.xml.dist
Expand Down Expand Up @@ -478,6 +475,6 @@ trigger:

---
kind: signature
hmac: 234ae9e7e2fbfa114ba754c68056dec518c76a93de2f5b098f569e355b50cc1b
hmac: d5db8148323f0205a8c0cd165da3934f5a77b25f73862d09ead95d3c42f1df01

...
7 changes: 3 additions & 4 deletions libraries/src/Feed/Parser/AtomParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,10 @@ protected function handleUpdated(Feed $feed, \SimpleXMLElement $el)
*/
protected function initialise()
{
// Read the version attribute.
$this->version = ($this->stream->getAttribute('version') == '0.3') ? '0.3' : '1.0';

// We want to move forward to the first element after the root element.
// We want to move forward to the first XML Element after the xml doc type declaration
$this->moveToNextElement();

$this->version = ($this->stream->getAttribute('version') == '0.3') ? '0.3' : '1.0';
}

/**
Expand Down
3 changes: 3 additions & 0 deletions libraries/src/Feed/Parser/RssParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ protected function handleWebmaster(Feed $feed, \SimpleXMLElement $el)
*/
protected function initialise()
{
// We want to move forward to the first XML Element after the xml doc type declaration
$this->moveToNextElement();

// Read the version attribute.
$this->version = $this->stream->getAttribute('version');

Expand Down
45 changes: 23 additions & 22 deletions plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,35 +87,36 @@ public function onDisplay(
// Prepare the instance specific options
if (empty($options['tinyMCE'][$fieldName]))
{
// Width and height
if ($width)
{
$options['tinyMCE'][$fieldName]['width'] = $width;
}
$options['tinyMCE'][$fieldName] = [];
}

if ($height)
{
$options['tinyMCE'][$fieldName]['height'] = $height;
}
// Width and height
if ($width && empty($options['tinyMCE'][$fieldName]['width']))
{
$options['tinyMCE'][$fieldName]['width'] = $width;
}

// Set editor to readonly mode
if (!empty($params['readonly']))
{
$options['tinyMCE'][$fieldName]['readonly'] = 1;
}
if ($height && empty($options['tinyMCE'][$fieldName]['height']))
{
$options['tinyMCE'][$fieldName]['height'] = $height;
}

// The ext-buttons
if (empty($options['tinyMCE'][$fieldName]['joomlaExtButtons']))
{
$btns = $this->tinyButtons($id, $buttons);
// Set editor to readonly mode
if (!empty($params['readonly']))
{
$options['tinyMCE'][$fieldName]['readonly'] = 1;
}

$options['tinyMCE'][$fieldName]['joomlaMergeDefaults'] = true;
$options['tinyMCE'][$fieldName]['joomlaExtButtons'] = $btns;
}
// The ext-buttons
if (empty($options['tinyMCE'][$fieldName]['joomlaExtButtons']))
{
$btns = $this->tinyButtons($id, $buttons);

$doc->addScriptOptions('plg_editor_tinymce', $options, false);
$options['tinyMCE'][$fieldName]['joomlaMergeDefaults'] = true;
$options['tinyMCE'][$fieldName]['joomlaExtButtons'] = $btns;
}

$doc->addScriptOptions('plg_editor_tinymce', $options, false);
// Setup Default (common) options for the Editor script

// Check whether we already have them
Expand Down
6 changes: 2 additions & 4 deletions tests/Unit/Libraries/Cms/Feed/FeedFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,14 @@ public function testRegisterParserWithInvalidTag()
public function testFetchFeedParser()
{
$tagName = 'parser-mock';
$xmlReaderMock = $this->createMock(XMLReader::class);
$parseMock = $this->createMock(FeedParser::class);
$this->feedFactory->registerParser($tagName, get_class($parseMock));

// Use reflection to test private method
$reflectionClass = new ReflectionClass($this->feedFactory);
$method = $reflectionClass->getMethod('_fetchFeedParser');
$method->setAccessible(true);
$parser = $method->invoke($this->feedFactory, $tagName, $xmlReaderMock);
$parser = $method->invoke($this->feedFactory, $tagName, new \XMLReader);

$this->assertInstanceOf(FeedParser::class, $parser);
$this->assertSame(get_class($parseMock), get_class($parser));
Expand All @@ -166,12 +165,11 @@ public function testFetchFeedParser()
public function testFetchFeedParserWithInvalidTag()
{
$this->expectException(\LogicException::class);
$xmlReaderMock = $this->createMock(XMLReader::class);

// Use reflection to test private method
$reflectionClass = new ReflectionClass($this->feedFactory);
$method = $reflectionClass->getMethod('_fetchFeedParser');
$method->setAccessible(true);
$method->invoke($this->feedFactory, 'not-existing', $xmlReaderMock);
$method->invoke($this->feedFactory, 'not-existing', new \XMLReader);
}
}
3 changes: 1 addition & 2 deletions tests/Unit/Libraries/Cms/Feed/FeedParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ public function testRegisterNamespace()
{
$prefix = 'my-namespace';
$namespaceMock = $this->createMock(NamespaceParserInterface::class);
$readerMock = $this->createMock(XMLReader::class);

$parser = new FeedParserStub($readerMock);
$parser = new FeedParserStub(new \XMLReader);
$returnedParser = $parser->registerNamespace($prefix, $namespaceMock);

$this->assertInstanceOf(FeedParserStub::class, $returnedParser);
Expand Down
79 changes: 45 additions & 34 deletions tests/Unit/Libraries/Cms/Feed/Parser/AtomParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testHandleAuthor()
->with($author['name'], $author['email'], $author['uri']);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleAuthor');
$method->setAccessible(true);
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testHandleContributor()
->with($contributor['name'], $contributor['email'], $contributor['uri']);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleContributor');
$method->setAccessible(true);
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testHandleGenerator()
->with('generator', $generator);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleGenerator');
$method->setAccessible(true);
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testHandleId()
->with('uri', $id);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleId');
$method->setAccessible(true);
Expand Down Expand Up @@ -191,7 +191,7 @@ function ($param) use ($href)
);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleLink');
$method->setAccessible(true);
Expand Down Expand Up @@ -221,7 +221,7 @@ public function testHandleRights()
->with('copyright', $copyright);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleRights');
$method->setAccessible(true);
Expand Down Expand Up @@ -251,7 +251,7 @@ public function testHandleSubtitle()
->with('description', $subtitle);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleSubtitle');
$method->setAccessible(true);
Expand Down Expand Up @@ -281,7 +281,7 @@ public function testHandleTitle()
->with('title', $title);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleTitle');
$method->setAccessible(true);
Expand Down Expand Up @@ -311,63 +311,74 @@ public function testHandleUpdated()
->with('updatedDate', $date);

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('handleUpdated');
$method->setAccessible(true);
$method->invoke($atomParser, $feedMock, $xmlElement);
}

/**
* Tests AtomParser::initialise()
* Tests AtomParser::parse()
*
* @return void
* @since 3.1.4
* @throws \ReflectionException
*/
public function testInitialiseSetsDefaultVersionWithXmlDocType()
{
$dummyXml = '<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" />';
$reader = \XMLReader::XML($dummyXml);
$atomParser = new AtomParser($reader);
$atomParser->parse();

// Use reflection to check the value
$reflectionClass = new ReflectionClass($atomParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

$this->assertEquals('1.0', $attribute->getValue($atomParser));
}

/**
* Tests AtomParser::parse()
*
* @return void
* @since 3.1.4
* @throws \ReflectionException
*/
public function testInitialiseSetsDefaultVersion()
{
$readerMock = $this->createMock(XMLReader::class);
$readerMock
->expects($this->once())
->method('getAttribute')
->with('version')
->willReturn('Some Version');
$dummyXml = '<feed xmlns="http://www.w3.org/2005/Atom" />';
$reader = \XMLReader::XML($dummyXml);
$atomParser = new AtomParser($reader);
$atomParser->parse();

// Use reflection to test protected method
$atomParser = new AtomParser($readerMock);
// Use reflection to check the value
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('initialise');
$method->setAccessible(true);
$method->invoke($atomParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

$this->assertEquals('1.0', $attribute->getValue($atomParser));
}

/**
* Tests AtomParser::initialise()
* Tests AtomParser::parse()
*
* @return void
* @since 3.1.4
* @throws \ReflectionException
*/
public function testInitialiseSetsOldVersion()
{
$readerMock = $this->createMock(XMLReader::class);
$readerMock
->expects($this->once())
->method('getAttribute')
->with('version')
->willReturn('0.3');
$dummyXml = '<feed version="0.3" xmlns="http://www.w3.org/2005/Atom" />';
$reader = \XMLReader::XML($dummyXml);
$atomParser = new AtomParser($reader);
$atomParser->parse();

// Use reflection to test protected method
$atomParser = new AtomParser($readerMock);
// Use reflection to check the value
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('initialise');
$method->setAccessible(true);
$method->invoke($atomParser);
$attribute = $reflectionClass->getProperty('version');
$attribute->setAccessible(true);

Expand Down Expand Up @@ -415,7 +426,7 @@ public function testProcessFeedEntry()
->will($this->returnValueMap($map));

// Use reflection to test protected method
$atomParser = new AtomParser($this->createMock(XMLReader::class));
$atomParser = new AtomParser(new \XMLReader);
$reflectionClass = new ReflectionClass($atomParser);
$method = $reflectionClass->getMethod('processFeedEntry');
$method->setAccessible(true);
Expand Down

0 comments on commit ac43036

Please sign in to comment.