data element for rel tag backcompat test', $item['properties']['content'][0]['html']);
@@ -918,7 +934,7 @@ public function testHEntryRelTagInContent() {
* @see https://github.com/indieweb/php-mf2/issues/157
* @see source: http://jg.typepad.com/ciel/2006/02/daniel_bouluds_.html
*/
- public function testHReviewRelTag() {
+ public function testHReviewRelTag(): void {
$input = '
@@ -948,13 +964,14 @@ public function testHReviewRelTag() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('category', $output['items'][0]['properties']);
$this->assertCount(2, $output['items'][0]['properties']['category']);
$this->assertContains('Garcon', $output['items'][0]['properties']['category']);
$this->assertContains('Garçon', $output['items'][0]['properties']['category']);
}
- public function testHReviewItemVevent()
+ public function testHReviewItemVevent(): void
{
$input = '
out of 5 stars
@@ -966,6 +983,7 @@ public function testHReviewItemVevent()
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('item', $output['items'][0]['properties']);
# assert item type is h-event
@@ -978,7 +996,7 @@ public function testHReviewItemVevent()
$this->assertArrayHasKey('url', $properties);
}
- public function testHReviewItemHproduct()
+ public function testHReviewItemHproduct(): void
{
$input = '
out of 5 stars
@@ -990,6 +1008,7 @@ public function testHReviewItemHproduct()
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('item', $output['items'][0]['properties']);
# assert item type is h-product
@@ -1006,7 +1025,7 @@ public function testHReviewItemHproduct()
* Should return the last non-empty URL segment
* @see https://github.com/indieweb/php-mf2/issues/157
*/
- public function testRelTagTrailingSlash() {
+ public function testRelTagTrailingSlash(): void {
$input = '
Testing,
Microformats
@@ -1020,9 +1039,11 @@ public function testRelTagTrailingSlash() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('category', $output['items'][0]['properties']);
$this->assertContains('testing', $output['items'][0]['properties']['category']);
$this->assertContains('microformats', $output['items'][0]['properties']['category']);
+ $this->assertIsArray($output['items'][1]['properties']);
$this->assertArrayHasKey('category', $output['items'][1]['properties']);
$this->assertContains('phpmf2', $output['items'][1]['properties']['category']);
$this->assertContains('mf2py', $output['items'][1]['properties']['category']);
@@ -1032,7 +1053,7 @@ public function testRelTagTrailingSlash() {
* Upgrade multiple mf1 roots on the same element
* @see https://github.com/indieweb/php-mf2/issues/156
*/
- public function testBackcompatMultipleRoots() {
+ public function testBackcompatMultipleRoots(): void {
$input = '
h-entry name
h-event name
@@ -1042,6 +1063,7 @@ public function testBackcompatMultipleRoots() {
$this->assertCount(2, $result['items'][0]['type']);
$this->assertContains('h-event', $result['items'][0]['type']);
$this->assertContains('h-entry', $result['items'][0]['type']);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertCount(2, $result['items'][0]['properties']['name']);
$this->assertContains('h-event name', $result['items'][0]['properties']['name']);
@@ -1051,7 +1073,7 @@ public function testBackcompatMultipleRoots() {
/**
* @see https://github.com/microformats/php-mf2/issues/195
*/
- public function testVcardGeoNoImpliedName() {
+ public function testVcardGeoNoImpliedName(): void {
$input = '
John Doe
Location: Brighton
@@ -1059,13 +1081,14 @@ public function testVcardGeoNoImpliedName() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']['geo'][0]['properties']);
}
/**
* @see https://github.com/microformats/php-mf2/issues/184
*/
- public function testVeventLocationVcardProperty() {
+ public function testVeventLocationVcardProperty(): void {
// Note: The venue for IWC 2012 no longer exists so we switched
// this to Powell's since it's a long-term Portland institution
$input = '
@@ -1086,6 +1109,7 @@ public function testVeventLocationVcardProperty() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
$this->assertEquals('h-card', $output['items'][0]['properties']['location'][0]['type'][0]);
@@ -1094,7 +1118,7 @@ public function testVeventLocationVcardProperty() {
/**
* @see https://github.com/microformats/php-mf2/issues/184
*/
- public function testVeventLocationAdrProperty() {
+ public function testVeventLocationAdrProperty(): void {
// date fix, see: https://cpj.org/2012/10/cpj-impact-43/
// "second annual Online Press Freedom Summit in San Francisco on October 10"
$input = '
@@ -1105,6 +1129,7 @@ public function testVeventLocationAdrProperty() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
$this->assertCount(1, $output['items'][0]['properties']['location'][0]['type']);
$this->assertEquals('h-adr', $output['items'][0]['properties']['location'][0]['type'][0]);
@@ -1113,7 +1138,7 @@ public function testVeventLocationAdrProperty() {
/**
* @see https://github.com/microformats/php-mf2/issues/184
*/
- public function testVeventLocationProperty() {
+ public function testVeventLocationProperty(): void {
// date fix, see: https://cpj.org/2012/10/cpj-impact-43/
// "second annual Online Press Freedom Summit in San Francisco on October 10"
$input = '
@@ -1124,6 +1149,7 @@ public function testVeventLocationProperty() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('location', $output['items'][0]['properties']);
$this->assertEquals('San Francisco', $output['items'][0]['properties']['location'][0]);
}
diff --git a/tests/Mf2/CombinedMicroformatsTest.php b/tests/Mf2/CombinedMicroformatsTest.php
index ae0638b..f07c37f 100644
--- a/tests/Mf2/CombinedMicroformatsTest.php
+++ b/tests/Mf2/CombinedMicroformatsTest.php
@@ -1,5 +1,7 @@
@@ -69,13 +71,13 @@ public function testHEventLocationHCard() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats2#combining_microformats
*/
- public function testHCardOrgPOrg() {
+ public function testHCardOrgPOrg(): void {
$input = '
parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats2#combining_microformats
*/
- public function testHCardOrgHCard() {
+ public function testHCardOrgHCard(): void {
$input = '
parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats2#combining_microformats
*/
- public function testHCardPOrgHCardHOrg() {
+ public function testHCardPOrgHCardHOrg(): void {
$input = '
parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats2#combining_microformats
*/
- public function testHCardChildHCard() {
+ public function testHCardChildHCard(): void {
$input = '
@@ -210,7 +212,7 @@ public function testHCardChildHCard() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
@@ -219,10 +221,11 @@ public function testHCardChildHCard() {
* This was occurring because mfPropertyNamesFromClass was only ever returning the first property name
* rather than all of them.
*/
- public function testNestedMicroformatUnderMultipleProperties() {
+ public function testNestedMicroformatUnderMultipleProperties(): void {
$input = ' ';
$mf = Mf2\parse($input);
+ $this->assertIsArray($mf['items'][0]['properties']);
$this->assertCount(1, $mf['items'][0]['properties']['like-of']);
$this->assertCount(1, $mf['items'][0]['properties']['in-reply-to']);
}
@@ -232,10 +235,11 @@ public function testNestedMicroformatUnderMultipleProperties() {
*
* @see https://github.com/indieweb/php-mf2/issues/64
*/
- public function testMicroformatsNestedUnderEPropertyClassnamesRetainHtmlKey() {
+ public function testMicroformatsNestedUnderEPropertyClassnamesRetainHtmlKey(): void {
$input = 'Hello
';
$mf = Mf2\parse($input);
+ $this->assertIsArray($mf['items'][0]['properties']);
$this->assertArrayHasKey('value', $mf['items'][0]['properties']['content'][0]);
$this->assertEquals($mf['items'][0]['properties']['content'][0]['value'], 'Hello');
$this->assertArrayHasKey('html', $mf['items'][0]['properties']['content'][0]);
@@ -245,13 +249,14 @@ public function testMicroformatsNestedUnderEPropertyClassnamesRetainHtmlKey() {
/**
* Test microformats nested under u-* property classnames derive value: key from parsing as u-*
*/
- public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueCorrectly() {
+ public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueCorrectly(): void {
$input = '
';
$mf = Mf2\parse($input);
- $this->assertEquals($mf['items'][0]['properties']['url'][0]['value'], 'This should be the value', json_encode($mf['items'][0]['properties']['url'][0]));
+ $this->assertIsArray($mf['items'][0]['properties']);
+ $this->assertEquals($mf['items'][0]['properties']['url'][0]['value'], 'This should be the value', json_encode($mf['items'][0]['properties']['url'][0], \JSON_THROW_ON_ERROR));
}
- public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueFromURL() {
+ public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueFromURL(): void {
$input = '
Name
Hello World
@@ -297,15 +302,17 @@ public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueFromURL
}';
$mf = Mf2\parse($input);
- $this->assertJsonStringEqualsJsonString(json_encode($mf), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($mf, \JSON_THROW_ON_ERROR), $expected);
+ $this->assertIsArray($mf['items'][0]['properties']);
$this->assertEquals($mf['items'][0]['properties']['comment'][0]['value'], 'https://example.com/post1234');
$this->assertEquals($mf['items'][0]['properties']['comment'][0]['properties']['author'][0]['value'], 'https://jane.example.com/');
}
- public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFirstPName() {
+ public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFirstPName(): void {
$input = '';
$mf = Mf2\parse($input);
+ $this->assertIsArray($mf['items'][0]['properties']);
$this->assertEquals($mf['items'][0]['properties']['author'][0]['value'], 'Zoe');
}
@@ -314,7 +321,7 @@ public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFir
* @see https://github.com/indieweb/php-mf2/issues/98
* @see https://github.com/microformats/tests/issues/58
*/
- public function testNoValueForNestedMicroformatWithoutProperty() {
+ public function testNoValueForNestedMicroformatWithoutProperty(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
@@ -330,7 +337,7 @@ public function testNoValueForNestedMicroformatWithoutProperty() {
* I fixed that but then wanted to ensure it worked beyond 1-level deep. This example
* is contrived, but lets me test to confirm 'children' is set correctly. - Gregor Morrill
*/
- public function testNestedMf1() {
+ public function testNestedMf1(): void {
$input = ' Jane Doe and John Doe ';
$parser = new Parser($input);
$output = $parser->parse();
@@ -345,7 +352,7 @@ public function testNestedMf1() {
$this->assertEquals('John Doe', $child_mf['children'][0]['properties']['name'][0]);
}
- public function testNoUrlFromRelOnMf2() {
+ public function testNoUrlFromRelOnMf2(): void {
$input = <<< END
@@ -355,6 +362,7 @@ public function testNoUrlFromRelOnMf2() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertArrayNotHasKey('url', $output['items'][0]['properties']);
@@ -365,7 +373,7 @@ public function testNoUrlFromRelOnMf2() {
* Whitespace cleaned up for easier test assertion
* @see https://github.com/indieweb/php-mf2/issues/151
*/
- public function testNestedValuePProperty() {
+ public function testNestedValuePProperty(): void {
$input = <<< END
@@ -378,6 +386,7 @@ public function testNestedValuePProperty() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('value', $output['items'][0]['properties']['location'][0]);
$this->assertEquals('Portland, Oregon • 44°F', $output['items'][0]['properties']['location'][0]['value']);
}
@@ -385,7 +394,7 @@ public function testNestedValuePProperty() {
/**
* @see https://github.com/indieweb/php-mf2/issues/151
*/
- public function testNestedValueDTProperty() {
+ public function testNestedValueDTProperty(): void {
$input = <<< END
1997-12-12
@@ -394,6 +403,7 @@ public function testNestedValueDTProperty() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('value', $output['items'][0]['properties']['acme'][0]);
$this->assertEquals('1997-12-12', $output['items'][0]['properties']['acme'][0]['value']);
}
@@ -402,7 +412,7 @@ public function testNestedValueDTProperty() {
* rel=tag should not be upgraded within microformats2
* @see https://github.com/indieweb/php-mf2/issues/157
*/
- public function testMf2DoesNotParseRelTag() {
+ public function testMf2DoesNotParseRelTag(): void {
$input = '
@@ -414,7 +424,9 @@ public function testMf2DoesNotParseRelTag() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('category', $output['items'][0]['properties']);
+ $this->assertIsArray($output['items'][1]['properties']);
$this->assertArrayNotHasKey('category', $output['items'][1]['properties']);
}
@@ -422,18 +434,18 @@ public function testMf2DoesNotParseRelTag() {
* JSON-mode should return an empty stdClass when a microformat has no properties.
* @see https://github.com/indieweb/php-mf2/issues/171
*/
- public function testEmptyPropertiesObjectInJSONMode() {
+ public function testEmptyPropertiesObjectInJSONMode(): void {
$input = '';
// Try in JSON-mode: expect the raw PHP to be an stdClass instance that serializes to an empty object.
$parser = new Parser($input, null, true);
$output = $parser->parse();
$this->assertInstanceOf('\stdClass', $output['items'][0]['properties']);
- $this->assertSame('{}', json_encode($output['items'][0]['properties']));
+ $this->assertSame('{}', json_encode($output['items'][0]['properties'], \JSON_THROW_ON_ERROR));
// Repeat in non-JSON-mode: expect the raw PHP to be an array. Check that its serialization is not what we need for mf2 JSON.
$parser = new Parser($input, null, false);
$output = $parser->parse();
$this->assertIsArray($output['items'][0]['properties']);
- $this->assertSame('[]', json_encode($output['items'][0]['properties']));
+ $this->assertSame('[]', json_encode($output['items'][0]['properties'], \JSON_THROW_ON_ERROR));
}
}
diff --git a/tests/Mf2/MicroformatsTestSuiteTest.php b/tests/Mf2/MicroformatsTestSuiteTest.php
index 9a90ede..7cb9f09 100644
--- a/tests/Mf2/MicroformatsTestSuiteTest.php
+++ b/tests/Mf2/MicroformatsTestSuiteTest.php
@@ -1,16 +1,19 @@
tagName) and in_array(strtolower($el->tagName), $excludeTags)) {
+ if ($el->tagName and in_array(strtolower($el->tagName), $excludeTags)) {
return '';
}
@@ -18,7 +21,8 @@ public function textContent(\DOMElement $el, $dummy = false) {
$clonedEl = $el->cloneNode(true);
- foreach ($this->xpath->query('.//img', $clonedEl) as $imgEl) {
+ /** @var DOMElement $imgEl */
+ foreach ($this->xpath->query('.//img', $clonedEl) ?: [] as $imgEl) {
if ($imgEl->hasAttribute('alt')) {
$replacement = $imgEl->getAttribute('alt');
} else if ($imgEl->hasAttribute('src')) {
@@ -31,7 +35,8 @@ public function textContent(\DOMElement $el, $dummy = false) {
}
foreach ($excludeTags as $tagName) {
- foreach ($this->xpath->query(".//{$tagName}", $clonedEl) as $elToRemove) {
+ /** @var DOMElement $elToRemove */
+ foreach ($this->xpath->query(".//{$tagName}", $clonedEl) ?: [] as $elToRemove) {
$elToRemove->parentNode->removeChild($elToRemove);
}
}
@@ -40,8 +45,8 @@ public function textContent(\DOMElement $el, $dummy = false) {
}
// Hack. Old textContent requires "resolveChildUrls", but that method is private.
- private $__resolveChildUrls = null;
- private function _resolveChildUrls(\DOMElement $element) {
+ private ?\ReflectionMethod $__resolveChildUrls = null;
+ private function _resolveChildUrls(\DOMElement $element): void {
if (null === $this->__resolveChildUrls) {
$reflectUpon = new \ReflectionClass($this);
$this->__resolveChildUrls = $reflectUpon->getMethod('resolveChildUrls');
@@ -49,7 +54,7 @@ private function _resolveChildUrls(\DOMElement $element) {
$this->__resolveChildUrls->setAccessible(true);
}
}
- return $this->__resolveChildUrls->invoke($this, $element);
+ $this->__resolveChildUrls->invoke($this, $element);
}
}
@@ -59,12 +64,12 @@ class MicroformatsTestSuiteTest extends TestCase
* @dataProvider mf1TestsProvider
* @group microformats/tests/mf1
*/
- public function testMf1FromTestSuite($input, $expectedOutput)
+ public function testMf1FromTestSuite(string $input, string $expectedOutput): void
{
$parser = new TestSuiteParser($input, 'http://example.com/');
$this->assertEquals(
$this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ $this->makeComparible(json_decode(json_encode($parser->parse(), \JSON_THROW_ON_ERROR), true))
);
}
@@ -72,7 +77,7 @@ public function testMf1FromTestSuite($input, $expectedOutput)
* @dataProvider mf2TestsProvider
* @group microformats/tests/mf2
*/
- public function testMf2FromTestSuite($input, $expectedOutput, $test)
+ public function testMf2FromTestSuite(string $input, string $expectedOutput, string $test): void
{
if ($test === 'h-event/time') {
$this->markTestIncomplete('This test does not match because we implement a proposed spec: https://github.com/microformats/microformats2-parsing/issues/4#issuecomment-373457720.');
@@ -81,7 +86,7 @@ public function testMf2FromTestSuite($input, $expectedOutput, $test)
$parser = new TestSuiteParser($input, 'http://example.com/');
$this->assertEquals(
$this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ $this->makeComparible(json_decode(json_encode($parser->parse(), \JSON_THROW_ON_ERROR), true))
);
}
@@ -89,12 +94,12 @@ public function testMf2FromTestSuite($input, $expectedOutput, $test)
* @dataProvider mixedTestsProvider
* @group microformats/tests/mixed
*/
- public function testMixedFromTestSuite($input, $expectedOutput)
+ public function testMixedFromTestSuite(string $input, string $expectedOutput): void
{
$parser = new TestSuiteParser($input, 'http://example.com/');
$this->assertEquals(
$this->makeComparible(json_decode($expectedOutput, true)),
- $this->makeComparible(json_decode(json_encode($parser->parse()), true))
+ $this->makeComparible(json_decode(json_encode($parser->parse(), \JSON_THROW_ON_ERROR), true))
);
}
@@ -103,15 +108,18 @@ public function testMixedFromTestSuite($input, $expectedOutput)
* * We sort arrays by key, normalising them, because JSON objects are unordered.
* * We json_encode strings, and cut the starting and ending ", so PHPUnit better
* shows whitespace characters like tabs and newlines.
- **/
- public function makeComparible($array)
+ *
+ * @param array $array
+ * @return array
+ */
+ public function makeComparible(array $array): array
{
ksort($array);
foreach ($array as $key => $value) {
if (gettype($value) === 'array') {
$array[$key] = $this->makeComparible($value);
} else if (gettype($value) === 'string') {
- $array[$key] = substr(json_encode($value), 1, -1);
+ $array[$key] = substr(json_encode($value, \JSON_THROW_ON_ERROR), 1, -1);
}
}
return $array;
@@ -119,8 +127,10 @@ public function makeComparible($array)
/**
* Data provider lists all tests from a specific directory in mf2/tests.
- **/
- public function htmlAndJsonProvider($subFolder = '')
+ *
+ * @return array
+ */
+ public function htmlAndJsonProvider(string $subFolder = ''): array
{
// Get the actual wanted subfolder.
$subFolder = '/mf2/tests/tests' . $subFolder;
@@ -137,13 +147,14 @@ public function htmlAndJsonProvider($subFolder = '')
$tests = array();
foreach ($finder as $key => $value) {
$dir = realpath(pathinfo($key, PATHINFO_DIRNAME));
+ assert($dir !== false); // For PHPStan
$testname = substr($dir, strpos($dir, $subFolder) + strlen($subFolder) + 1) . '/' . pathinfo($key, PATHINFO_FILENAME);
$test = pathinfo($key, PATHINFO_BASENAME);
$result = pathinfo($key, PATHINFO_FILENAME) . '.json';
if (is_file($dir . '/' . $result)) {
$tests[$testname] = array(
- 'input' => file_get_contents($dir . '/' . $test),
- 'expectedOutput' => file_get_contents($dir . '/' . $result),
+ 'input' => file_get_contents($dir . '/' . $test) ?: '',
+ 'expectedOutput' => file_get_contents($dir . '/' . $result) ?: '',
'name' => $testname
);
}
@@ -153,18 +164,26 @@ public function htmlAndJsonProvider($subFolder = '')
/**
* Following three functions are the actual dataProviders used by the test methods.
+ *
+ * @return array
*/
- public function mf1TestsProvider()
+ public function mf1TestsProvider(): array
{
return $this->htmlAndJsonProvider('/microformats-v1');
}
- public function mf2TestsProvider()
+ /**
+ * @return array
+ */
+ public function mf2TestsProvider(): array
{
return $this->htmlAndJsonProvider('/microformats-v2');
}
- public function mixedTestsProvider()
+ /**
+ * @return array
+ */
+ public function mixedTestsProvider(): array
{
return $this->htmlAndJsonProvider('/microformats-mixed');
}
diff --git a/tests/Mf2/MicroformatsWikiExamplesTest.php b/tests/Mf2/MicroformatsWikiExamplesTest.php
index d3d0777..645c3b5 100644
--- a/tests/Mf2/MicroformatsWikiExamplesTest.php
+++ b/tests/Mf2/MicroformatsWikiExamplesTest.php
@@ -4,6 +4,8 @@
* Tests of the parsing methods within mf2\Parser
*/
+declare (strict_types=1);
+
namespace Mf2\Parser\Test;
use Mf2\Parser;
@@ -25,7 +27,7 @@ protected function set_up() {
date_default_timezone_set('Europe/London');
}
- public function testHandlesEmptyStringsCorrectly() {
+ public function testHandlesEmptyStringsCorrectly(): void {
$input = '';
$expected = '{
"rels": {},
@@ -36,10 +38,10 @@ public function testHandlesEmptyStringsCorrectly() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
- public function testHandlesNullCorrectly() {
+ public function testHandlesNullCorrectly(): void {
$input = null;
$expected = '{
"rels": {},
@@ -51,13 +53,13 @@ public function testHandlesNullCorrectly() {
$parser->jsonMode = true;
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2
*/
- public function testSimplePersonReference() {
+ public function testSimplePersonReference(): void {
$input = 'Frances Berriman';
$expected = '{
"rels": {},
@@ -72,13 +74,13 @@ public function testSimplePersonReference() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2
*/
- public function testSimpleHyperlinkedPersonReference() {
+ public function testSimpleHyperlinkedPersonReference(): void {
$input = 'Ben Ward';
$expected = '{
"rels": {},
@@ -94,13 +96,13 @@ public function testSimpleHyperlinkedPersonReference() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2-implied-properties
*/
- public function testSimplePersonImage() {
+ public function testSimplePersonImage(): void {
$input = '
';
// Added root items key
$expected = '{
@@ -119,13 +121,13 @@ public function testSimplePersonImage() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2-implied-properties
*/
- public function testHyperlinkedImageNameAndPhotoProperties() {
+ public function testHyperlinkedImageNameAndPhotoProperties(): void {
$input = '
@@ -148,13 +150,13 @@ public function testHyperlinkedImageNameAndPhotoProperties() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2
*/
- public function testMoreDetailedPerson() {
+ public function testMoreDetailedPerson(): void {
$input = '
@@ -201,6 +203,6 @@ public function testMoreDetailedPerson() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
}
diff --git a/tests/Mf2/ParseDTTest.php b/tests/Mf2/ParseDTTest.php
index 29252de..f82bec9 100644
--- a/tests/Mf2/ParseDTTest.php
+++ b/tests/Mf2/ParseDTTest.php
@@ -1,5 +1,7 @@
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -32,11 +35,12 @@ public function testParseDTHandlesImg() {
/**
* @group parseDT
*/
- public function testParseDTHandlesDataValueAttr() {
+ public function testParseDTHandlesDataValueAttr(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -44,11 +48,12 @@ public function testParseDTHandlesDataValueAttr() {
/**
* @group parseDT
*/
- public function testParseDTHandlesDataInnerHTML() {
+ public function testParseDTHandlesDataInnerHTML(): void {
$input = '2012-08-05T14:50';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -56,11 +61,12 @@ public function testParseDTHandlesDataInnerHTML() {
/**
* @group parseDT
*/
- public function testParseDTHandlesAbbrValueAttr() {
+ public function testParseDTHandlesAbbrValueAttr(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -68,11 +74,12 @@ public function testParseDTHandlesAbbrValueAttr() {
/**
* @group parseDT
*/
- public function testParseDTHandlesAbbrInnerHTML() {
+ public function testParseDTHandlesAbbrInnerHTML(): void {
$input = '2012-08-05T14:50';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -80,11 +87,12 @@ public function testParseDTHandlesAbbrInnerHTML() {
/**
* @group parseDT
*/
- public function testParseDTHandlesTimeDatetimeAttr() {
+ public function testParseDTHandlesTimeDatetimeAttr(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -92,11 +100,12 @@ public function testParseDTHandlesTimeDatetimeAttr() {
/**
* @group parseDT
*/
- public function testParseDTHandlesTimeDatetimeAttrWithZ() {
+ public function testParseDTHandlesTimeDatetimeAttrWithZ(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50:00Z', $output['items'][0]['properties']['start'][0]);
}
@@ -104,11 +113,12 @@ public function testParseDTHandlesTimeDatetimeAttrWithZ() {
/**
* @group parseDT
*/
- public function testParseDTHandlesTimeDatetimeAttrWithTZOffset() {
+ public function testParseDTHandlesTimeDatetimeAttrWithTZOffset(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50:00-0700', $output['items'][0]['properties']['start'][0]);
}
@@ -116,11 +126,12 @@ public function testParseDTHandlesTimeDatetimeAttrWithTZOffset() {
/**
* @group parseDT
*/
- public function testParseDTHandlesTimeDatetimeAttrWithTZOffset2() {
+ public function testParseDTHandlesTimeDatetimeAttrWithTZOffset2(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50:00-07:00', $output['items'][0]['properties']['start'][0]);
}
@@ -128,11 +139,12 @@ public function testParseDTHandlesTimeDatetimeAttrWithTZOffset2() {
/**
* @group parseDT
*/
- public function testParseDTHandlesTimeInnerHTML() {
+ public function testParseDTHandlesTimeInnerHTML(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
}
@@ -140,11 +152,12 @@ public function testParseDTHandlesTimeInnerHTML() {
/**
* @group parseDT
*/
- public function testParseDTHandlesInsDelDatetime() {
+ public function testParseDTHandlesInsDelDatetime(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertArrayHasKey('end', $output['items'][0]['properties']);
$this->assertEquals('2012-08-05T14:50', $output['items'][0]['properties']['start'][0]);
@@ -155,11 +168,12 @@ public function testParseDTHandlesInsDelDatetime() {
* @group parseDT
* @group valueClass
*/
- public function testYYYY_MM_DD__HH_MM() {
+ public function testYYYY_MM_DD__HH_MM(): void {
$input = '2012-10-07 at 21:18';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-10-07 21:18', $output['items'][0]['properties']['start'][0]);
}
@@ -168,11 +182,12 @@ public function testYYYY_MM_DD__HH_MM() {
* @group parseDT
* @group valueClass
*/
- public function testAbbrYYYY_MM_DD__HH_MM() {
+ public function testAbbrYYYY_MM_DD__HH_MM(): void {
$input = 'some day at 21:18';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-10-07 21:18', $output['items'][0]['properties']['start'][0]);
}
@@ -181,11 +196,12 @@ public function testAbbrYYYY_MM_DD__HH_MM() {
* @group parseDT
* @group valueClass
*/
- public function testYYYY_MM_DD__HHpm() {
+ public function testYYYY_MM_DD__HHpm(): void {
$input = '2012-10-07 at 9pm';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-10-07 21:00', $output['items'][0]['properties']['start'][0]);
}
@@ -194,11 +210,12 @@ public function testYYYY_MM_DD__HHpm() {
* @group parseDT
* @group valueClass
*/
- public function testYYYY_MM_DD__HH_MMpm() {
+ public function testYYYY_MM_DD__HH_MMpm(): void {
$input = '2012-10-07 at 9:00pm';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-10-07 21:00', $output['items'][0]['properties']['start'][0]);
}
@@ -207,11 +224,12 @@ public function testYYYY_MM_DD__HH_MMpm() {
* @group parseDT
* @group valueClass
*/
- public function testYYYY_MM_DD__HH_MM_SSpm() {
+ public function testYYYY_MM_DD__HH_MM_SSpm(): void {
$input = '2012-10-07 at 9:00:00pm';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2012-10-07 21:00:00', $output['items'][0]['properties']['start'][0]);
}
@@ -221,11 +239,12 @@ public function testYYYY_MM_DD__HH_MM_SSpm() {
* @group parseDT
* @group valueClass
*/
- public function testImpliedDTEndWithValueClass() {
+ public function testImpliedDTEndWithValueClass(): void {
$input = ' 2014-06-04 at 18:30 19:30 ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertArrayHasKey('end', $output['items'][0]['properties']);
$this->assertEquals('2014-06-04 18:30', $output['items'][0]['properties']['start'][0]);
@@ -237,12 +256,13 @@ public function testImpliedDTEndWithValueClass() {
* @group parseDT
* @group valueClass
*/
- public function testImpliedDTEndWithoutValueClass() {
+ public function testImpliedDTEndWithoutValueClass(): void {
$input = ' 2014-06-05 at 18:31 19:31 ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertArrayHasKey('end', $output['items'][0]['properties']);
$this->assertEquals('2014-06-05 18:31', $output['items'][0]['properties']['start'][0]);
@@ -254,12 +274,13 @@ public function testImpliedDTEndWithoutValueClass() {
* @group parseDT
* @group valueClass
*/
- public function testImpliedDTEndUsingNonValueClassDTStart() {
+ public function testImpliedDTEndUsingNonValueClassDTStart(): void {
$input = ' until 19:31 ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertArrayHasKey('end', $output['items'][0]['properties']);
$this->assertEquals('2014-06-05T18:31', $output['items'][0]['properties']['start'][0]);
@@ -270,11 +291,12 @@ public function testImpliedDTEndUsingNonValueClassDTStart() {
* @group parseDT
* @group valueClass
*/
- public function testDTStartOnly() {
+ public function testDTStartOnly(): void {
$input = ' 2014-06-06 at 18:32 ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2014-06-06 18:32', $output['items'][0]['properties']['start'][0]);
$this->assertArrayNotHasKey('end', $output['items'][0]['properties']);
@@ -284,11 +306,12 @@ public function testDTStartOnly() {
* @group parseDT
* @group valueClass
*/
- public function testDTStartDateOnly() {
+ public function testDTStartDateOnly(): void {
$input = ' 2014-06-07 ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('start', $output['items'][0]['properties']);
$this->assertEquals('2014-06-07', $output['items'][0]['properties']['start'][0]);
}
@@ -298,7 +321,7 @@ public function testDTStartDateOnly() {
* This behavior is implied from "However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged in order to make it less likely that a timezone offset will be confused for a time."
* @see https://microformats.org/wiki/index.php?title=value-class-pattern&oldid=66473##However+the+colons
*/
- public function testNormalizeTZOffsetVCP() {
+ public function testNormalizeTZOffsetVCP(): void {
$input = '
, from
@@ -306,6 +329,7 @@ public function testNormalizeTZOffsetVCP() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-05-27 20:57-0700', $output['items'][0]['properties']['start'][0]);
}
@@ -313,11 +337,12 @@ public function testNormalizeTZOffsetVCP() {
/**
* TZ offsets *not* normalized for non-VCP dates
*/
- public function testNoNormalizeTZOffset() {
+ public function testNoNormalizeTZOffset(): void {
$input = ' ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2018-03-13 15:30-07:00', $output['items'][0]['properties']['start'][0]);
}
@@ -325,7 +350,7 @@ public function testNoNormalizeTZOffset() {
/**
* @see https://github.com/indieweb/php-mf2/issues/115
*/
- public function testDoNotAddT() {
+ public function testDoNotAddT(): void {
$input = '
, from
@@ -335,24 +360,26 @@ public function testDoNotAddT() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2009-06-26 19:00:00-0800', $output['items'][0]['properties']['start'][0]);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/115
*/
- public function testPreserrveTIfAuthored() {
+ public function testPreserrveTIfAuthored(): void {
$input = ' ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2009-06-26T19:01-08:00', $output['items'][0]['properties']['start'][0]);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/126
*/
- public function testDtVCPTimezone() {
+ public function testDtVCPTimezone(): void {
$input = '
HomebrewWebsiteClub Berlin will be next on
@@ -362,6 +389,7 @@ public function testDtVCPTimezone() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-05-31 19:00+0200', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-05-31 21:00+0200', $output['items'][0]['properties']['end'][0]);
}
@@ -369,7 +397,7 @@ public function testDtVCPTimezone() {
/**
* @see https://github.com/indieweb/php-mf2/issues/126
*/
- public function testDtVCPTimezoneShort() {
+ public function testDtVCPTimezoneShort(): void {
$input = '
HomebrewWebsiteClub Berlin will be next on
@@ -379,6 +407,7 @@ public function testDtVCPTimezoneShort() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-05-31 19:00+0200', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-05-31 21:00+0200', $output['items'][0]['properties']['end'][0]);
}
@@ -386,7 +415,7 @@ public function testDtVCPTimezoneShort() {
/**
* @see https://github.com/indieweb/php-mf2/issues/126
*/
- public function testDtVCPTimezoneNoLeadingZero() {
+ public function testDtVCPTimezoneNoLeadingZero(): void {
$input = '
2017-06-17
@@ -400,6 +429,7 @@ public function testDtVCPTimezoneNoLeadingZero() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-06-17 22:00-0700', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-06-17 23:00-0700', $output['items'][0]['properties']['end'][0]);
}
@@ -407,11 +437,12 @@ public function testDtVCPTimezoneNoLeadingZero() {
/**
* @see https://github.com/microformats/microformats2-parsing/issues/4
*/
- public function testImplyTimezoneFromStart() {
+ public function testImplyTimezoneFromStart(): void {
$input = ' to ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2014-09-11 13:30-0700', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2014-09-11 15:30-0700', $output['items'][0]['properties']['end'][0]);
}
@@ -419,11 +450,12 @@ public function testImplyTimezoneFromStart() {
/**
* @see https://github.com/microformats/microformats2-parsing/issues/4
*/
- public function testImplyTimezoneFromEnd() {
+ public function testImplyTimezoneFromEnd(): void {
$input = ' to ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2014-09-11 13:30-0700', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2014-09-11 15:30-0700', $output['items'][0]['properties']['end'][0]);
}
@@ -431,7 +463,7 @@ public function testImplyTimezoneFromEnd() {
/**
*
*/
- public function testAMPMWithPeriods() {
+ public function testAMPMWithPeriods(): void {
$input = '
2017-06-11
@@ -445,6 +477,7 @@ public function testAMPMWithPeriods() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-06-11 22:00', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-06-12 02:00', $output['items'][0]['properties']['end'][0]);
}
@@ -452,7 +485,7 @@ public function testAMPMWithPeriods() {
/**
*
*/
- public function testAMPMWithoutPeriods() {
+ public function testAMPMWithoutPeriods(): void {
$input = '
2017-06-17
@@ -466,6 +499,7 @@ public function testAMPMWithoutPeriods() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-06-17 22:30', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-06-18 02:30', $output['items'][0]['properties']['end'][0]);
}
@@ -473,7 +507,7 @@ public function testAMPMWithoutPeriods() {
/**
*
*/
- public function testDtVCPTimeAndTimezone() {
+ public function testDtVCPTimeAndTimezone(): void {
$input = '
2017-06-17
@@ -487,6 +521,7 @@ public function testDtVCPTimeAndTimezone() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2017-06-17 13:30-0700', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2017-06-17 15:30-0700', $output['items'][0]['properties']['end'][0]);
}
@@ -494,7 +529,7 @@ public function testDtVCPTimeAndTimezone() {
/**
* @see https://github.com/indieweb/php-mf2/issues/147
*/
- public function testDtVCPMultipleDatesAndTimezones() {
+ public function testDtVCPMultipleDatesAndTimezones(): void {
$input = '
Multiple date and time values
@@ -514,6 +549,7 @@ public function testDtVCPMultipleDatesAndTimezones() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2014-06-01 12:30-0600', $output['items'][0]['properties']['start'][0]);
$this->assertEquals('2014-06-01 19:30-0600', $output['items'][0]['properties']['end'][0]);
}
@@ -521,11 +557,12 @@ public function testDtVCPMultipleDatesAndTimezones() {
/**
* @see https://github.com/indieweb/php-mf2/issues/149
*/
- public function testDtWithoutYear() {
+ public function testDtWithoutYear(): void {
$input = ' ';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('--12-28', $output['items'][0]['properties']['bday'][0]);
}
@@ -533,7 +570,7 @@ public function testDtWithoutYear() {
* @see https://github.com/indieweb/php-mf2/issues/167
* @see https://github.com/microformats/mf2py/blob/master/test/examples/datetimes.html
*/
- public function testNormalizeOrdinalDate() {
+ public function testNormalizeOrdinalDate(): void {
$input = '
Ordinal date
When:
@@ -546,6 +583,7 @@ public function testNormalizeOrdinalDate() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2016-03-02 12:30-0600', $output['items'][0]['properties']['start'][0]);
}
}
diff --git a/tests/Mf2/ParseHtmlIdTest.php b/tests/Mf2/ParseHtmlIdTest.php
index d00390c..614fcbc 100644
--- a/tests/Mf2/ParseHtmlIdTest.php
+++ b/tests/Mf2/ParseHtmlIdTest.php
@@ -1,4 +1,7 @@
Recent Articles
Lorem Ipsum
empty id should not be parsed
@@ -28,8 +31,10 @@ public function testParserIdAttribute() {
$result = Mf2\parse($test);
$this->assertArrayHasKey('id', $result['items'][0]);
$this->assertEquals('recentArticles', $result['items'][0]['id']);
+ $this->assertArrayHasKey('children', $result['items'][0]);
$this->assertArrayHasKey('id', $result['items'][0]['children'][0]);
$this->assertEquals('article', $result['items'][0]['children'][0]['id']);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('id', $result['items'][0]['properties']['author'][0]);
$this->assertEquals('theAuthor', $result['items'][0]['properties']['author'][0]['id']);
$this->assertArrayNotHasKey('id', $result['items'][0]['children'][1]);
diff --git a/tests/Mf2/ParseImpliedTest.php b/tests/Mf2/ParseImpliedTest.php
index a11e400..99bdbb5 100644
--- a/tests/Mf2/ParseImpliedTest.php
+++ b/tests/Mf2/ParseImpliedTest.php
@@ -1,4 +1,7 @@
The Name';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('The Name', $output['items'][0]['properties']['name'][0]);
}
- public function testParsesImpliedPNameFromImgAlt() {
+ public function testParsesImpliedPNameFromImgAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('The Name', $output['items'][0]['properties']['name'][0]);
}
- public function testParsesImpliedPNameFromNestedImgAlt() {
+ public function testParsesImpliedPNameFromNestedImgAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('The Name', $output['items'][0]['properties']['name'][0]);
}
- public function testParsesImpliedPNameFromDoublyNestedImgAlt() {
+ public function testParsesImpliedPNameFromDoublyNestedImgAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('The Name', $output['items'][0]['properties']['name'][0]);
}
- public function testParsesImpliedUPhotoFromImgSrcWithoutAlt() {
+ public function testParsesImpliedUPhotoFromImgSrcWithoutAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]);
}
- public function testParsesImpliedUPhotoFromImgSrcWithEmptyAlt() {
+ public function testParsesImpliedUPhotoFromImgSrcWithEmptyAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]['value']);
$this->assertEquals('', $output['items'][0]['properties']['photo'][0]['alt']);
}
- public function testParsesImpliedUPhotoFromImgSrcWithAlt() {
+ public function testParsesImpliedUPhotoFromImgSrcWithAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]['value']);
$this->assertEquals('Example', $output['items'][0]['properties']['photo'][0]['alt']);
}
- public function testParsesImpliedUPhotoFromNestedImgSrc() {
+ public function testParsesImpliedUPhotoFromNestedImgSrc(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$return = [
'value' => 'https://example.com/img.png',
@@ -96,11 +107,12 @@ public function testParsesImpliedUPhotoFromNestedImgSrc() {
$this->assertEquals( $return, $output['items'][0]['properties']['photo'][0]);
}
- public function testParsesImpliedUPhotoFromDoublyNestedImgSrc() {
+ public function testParsesImpliedUPhotoFromDoublyNestedImgSrc(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$result = [
'alt' => '',
@@ -116,6 +128,7 @@ public function testIgnoresImgIfNotOnlyChild() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $output['items'][0]['properties']);
}
@@ -124,49 +137,54 @@ public function testIgnoresDoublyNestedImgIfNotOnlyDoublyNestedChild() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $output['items'][0]['properties']);
}
*/
- public function testParsesImpliedUUrlFromAHref() {
+ public function testParsesImpliedUUrlFromAHref(): void {
$input = 'Some Name';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
}
- public function testParsesImpliedUUrlFromNestedAHref() {
+ public function testParsesImpliedUUrlFromNestedAHref(): void {
$input = 'Some Name';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
}
- public function testParsesImpliedUUrlWithExplicitName() {
+ public function testParsesImpliedUUrlWithExplicitName(): void {
$input = 'Some Name';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
}
- public function testParsesImpliedNameWithExplicitURL() {
+ public function testParsesImpliedNameWithExplicitURL(): void {
$input = 'Some Name';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
$this->assertEquals('Some Name', $output['items'][0]['properties']['name'][0]);
}
- public function testMultipleImpliedHCards() {
+ public function testMultipleImpliedHCards(): void {
$input = 'Frances Berriman
Ben Ward
@@ -219,30 +237,34 @@ public function testMultipleImpliedHCards() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/** as per https://github.com/indieweb/php-mf2/issues/37 */
- public function testParsesImpliedNameConsistentWithPName() {
+ public function testParsesImpliedNameConsistentWithPName(): void {
$inner = "Name \nand more";
$test = ' ' . $inner .' ' . $inner . ' ';
$result = Mf2\parse($test);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('Name and more', $result['items'][0]['properties']['name'][0]);
+ $this->assertIsArray($result['items'][1]['properties']);
$this->assertEquals('Name and more', $result['items'][1]['properties']['name'][0]);
}
/** @see https://github.com/indieweb/php-mf2/issues/6 */
- public function testParsesImpliedNameFromAbbrTitle() {
+ public function testParsesImpliedNameFromAbbrTitle(): void {
$input = 'BJW';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('Barnaby Walters', $result['items'][0]['properties']['name'][0]);
}
- public function testImpliedPhotoFromObject() {
+ public function testImpliedPhotoFromObject(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('photo', $result['items'][0]['properties']);
$this->assertEquals('http://example/photo1.jpg', $result['items'][0]['properties']['photo'][0]);
}
@@ -252,18 +274,20 @@ public function testImpliedPhotoFromObject() {
* This *should* return the photo since h-x>img[src]:only-of-type:not[.h-*]
* @see https://indieweb.org/User:Tantek.com
*/
- public function testImpliedPhotoFromNestedImg() {
+ public function testImpliedPhotoFromNestedImg(): void {
$input = '
Tantek Çelik';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('photo', $result['items'][0]['properties']);
$this->assertEquals('https://pbs.twimg.com/profile_images/423350922408767488/nlA_m2WH.jpeg', $result['items'][0]['properties']['photo'][0]);
}
- public function testIgnoredPhotoIfMultipleImg() {
+ public function testIgnoredPhotoIfMultipleImg(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
@@ -271,79 +295,88 @@ public function testIgnoredPhotoIfMultipleImg() {
* Correcting previous test testIgnoresDoublyNestedImgIfNotOnlyDoublyNestedChild()
* This *should* return the photo since .h-x>object[data]:only-of-type:not[.h-*]
*/
- public function testImpliedPhotoFromNestedObject() {
+ public function testImpliedPhotoFromNestedObject(): void {
$input = ' Moar text
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('photo', $result['items'][0]['properties']);
$this->assertEquals('http://example/photo3.jpg', $result['items'][0]['properties']['photo'][0]);
}
- public function testIgnoredPhotoIfMultipleObject() {
+ public function testIgnoredPhotoIfMultipleObject(): void {
$input = ' ';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
- public function testIgnoredPhotoIfNestedImgH() {
+ public function testIgnoredPhotoIfNestedImgH(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
- public function testIgnoredPhotoIfNestedImgHasHClass() {
+ public function testIgnoredPhotoIfNestedImgHasHClass(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
- public function testIgnoredPhotoIfNestedObjectHasHClass() {
+ public function testIgnoredPhotoIfNestedObjectHasHClass(): void {
$input = ' ';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/176
*/
- public function testIgnoredPhotoImgInNestedH() {
+ public function testIgnoredPhotoImgInNestedH(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/176
*/
- public function testIgnoredPhotoObjectInNestedH() {
+ public function testIgnoredPhotoObjectInNestedH(): void {
$input = ' ';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/190
*/
- public function testIgnoredMultiChildrenWithNestedPhotoImg() {
+ public function testIgnoredMultiChildrenWithNestedPhotoImg(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/190
*/
- public function testIgnoredMultiChildrenWithNestedPhotoObject() {
+ public function testIgnoredMultiChildrenWithNestedPhotoObject(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
@@ -351,10 +384,11 @@ public function testIgnoredMultiChildrenWithNestedPhotoObject() {
* Imply properties only on explicit h-x class name root microformat element (no backcompat roots)
* @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties
*/
- public function testBackcompatNoImpliedName() {
+ public function testBackcompatNoImpliedName(): void {
$input = ' blah blah blah
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $result['items'][0]['properties']);
$this->assertArrayHasKey('content', $result['items'][0]['properties']);
}
@@ -364,10 +398,11 @@ public function testBackcompatNoImpliedName() {
* Imply properties only on explicit h-x class name root microformat element (no backcompat roots)
* @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties
*/
- public function testBackcompatNoImpliedPhoto() {
+ public function testBackcompatNoImpliedPhoto(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEmpty($result['items'][0]['properties']);
}
@@ -376,10 +411,11 @@ public function testBackcompatNoImpliedPhoto() {
* Imply properties only on explicit h-x class name root microformat element (no backcompat roots)
* @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties
*/
- public function testBackcompatNoImpliedUrl() {
+ public function testBackcompatNoImpliedUrl(): void {
$input = ' Title blah blah blah
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('url', $result['items'][0]['properties']);
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertArrayHasKey('content', $result['items'][0]['properties']);
@@ -391,10 +427,11 @@ public function testBackcompatNoImpliedUrl() {
* @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties
* @see https://github.com/microformats/php-mf2/issues/183
*/
- public function testNoImpliedUrl() {
+ public function testNoImpliedUrl(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('url', $result['items'][0]['properties']);
}
@@ -402,10 +439,11 @@ public function testNoImpliedUrl() {
* Do not use img src in implied p-name
* @see https://github.com/microformats/php-mf2/issues/180
*/
- public function testNoImgSrcImpliedName() {
+ public function testNoImgSrcImpliedName(): void {
$input = 'My Name 
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('name', $result['items'][0]['properties']);
$this->assertEquals('My Name', $result['items'][0]['properties']['name'][0]);
}
@@ -413,20 +451,22 @@ public function testNoImgSrcImpliedName() {
/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
- public function testNoImpliedPhotoWhenExplicitUProperty() {
+ public function testNoImpliedPhotoWhenExplicitUProperty(): void {
$input = ' Organization Name
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
}
/**
* @see https://github.com/microformats/php-mf2/issues/198
*/
- public function testNoImpliedPhotoWhenNestedMicroformat() {
+ public function testNoImpliedPhotoWhenNestedMicroformat(): void {
$input = '
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']);
$this->assertArrayHasKey('author', $result['items'][0]['properties']);
$this->assertArrayNotHasKey('photo', $result['items'][0]['properties']['author'][0]['properties']);
diff --git a/tests/Mf2/ParseLanguageTest.php b/tests/Mf2/ParseLanguageTest.php
index 1e7af0d..b456b70 100644
--- a/tests/Mf2/ParseLanguageTest.php
+++ b/tests/Mf2/ParseLanguageTest.php
@@ -1,5 +1,7 @@
*/
- public function testHtmlLangOnly()
+ public function testHtmlLangOnly(): void
{
$input = ' This test is in English. ';
$parser = new Parser($input);
@@ -33,7 +35,7 @@ public function testHtmlLangOnly()
/**
* Test with only h-entry lang
*/
- public function testHEntryLangOnly()
+ public function testHEntryLangOnly(): void
{
$input = ' This test is in English. ';
$parser = new Parser($input);
@@ -47,7 +49,7 @@ public function testHEntryLangOnly()
/**
* Test with different and h-entry lang
*/
- public function testHtmlAndHEntryLang()
+ public function testHtmlAndHEntryLang(): void
{
$input = ' Esta prueba está en español. ';
$parser = new Parser($input);
@@ -61,7 +63,7 @@ public function testHtmlAndHEntryLang()
/**
* Test HTML fragment with only h-entry lang
*/
- public function testFragmentHEntryLangOnly()
+ public function testFragmentHEntryLangOnly(): void
{
$input = 'This test is in English.';
$parser = new Parser($input);
@@ -75,7 +77,7 @@ public function testFragmentHEntryLangOnly()
/**
* Test HTML fragment with no lang
*/
- public function testFragmentHEntryNoLang()
+ public function testFragmentHEntryNoLang(): void
{
$input = 'This test is in English.';
$parser = new Parser($input);
@@ -88,7 +90,7 @@ public function testFragmentHEntryNoLang()
/**
* Test HTML fragment with no lang, loaded with loadXML()
*/
- public function testFragmentHEntryNoLangXML()
+ public function testFragmentHEntryNoLangXML(): void
{
$input = new \DOMDocument();
$input->loadXML('This test is in English.');
@@ -102,7 +104,7 @@ public function testFragmentHEntryNoLangXML()
* Test with different , h-entry lang, and h-entry without lang,
* which should inherit from the
*/
- public function testMultiLanguageInheritance()
+ public function testMultiLanguageInheritance(): void
{
$input = ' This test is in English. Esta prueba está en español. ';
$parser = new Parser($input);
@@ -119,7 +121,7 @@ public function testMultiLanguageInheritance()
* Test feed with .h-feed lang which contains multiple h-entries of different languages
* (or none specified), which should inherit from the .h-feed lang.
*/
- public function testMultiLanguageFeed()
+ public function testMultiLanguageFeed(): void
{
$input = ' Test Feed
This test is in English. Esta prueba está en español. Ce test est en français. ';
$parser = new Parser($input);
@@ -129,6 +131,7 @@ public function testMultiLanguageFeed()
$this->assertArrayHasKey('lang', $result['items'][0]);
$this->assertEquals('en', $result['items'][0]['lang']);
+ $this->assertArrayHasKey('children', $result['items'][0]);
$this->assertArrayHasKey('lang', $result['items'][0]['children'][0]);
$this->assertEquals('en', $result['items'][0]['children'][0]['lang']);
@@ -142,7 +145,7 @@ public function testMultiLanguageFeed()
/**
* Test with language specified in http-equiv Content-Language
*/
- public function testMetaContentLanguage()
+ public function testMetaContentLanguage(): void
{
$input = ' Esta prueba está en español. ';
$parser = new Parser($input);
@@ -157,7 +160,7 @@ public function testMetaContentLanguage()
* Test with real-world post on voxpelli.com
* @see http://voxpelli.com/2015/09/oberoende-sociala-webben-2015/
*/
- public function testVoxpelliCom()
+ public function testVoxpelliCom(): void
{
$input = <<< END
@@ -252,7 +255,7 @@ public function testVoxpelliCom()
/**
* @see https://github.com/indieweb/php-mf2/issues/96#issuecomment-304457341
*/
- public function testNoLangInParsedProperties() {
+ public function testNoLangInParsedProperties(): void {
$input = '
En svensk titel
With an english summary
@@ -262,6 +265,7 @@ public function testNoLangInParsedProperties() {
$parser->lang = true;
$result = $parser->parse();
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayNotHasKey('lang', $result['items'][0]['properties']);
$this->assertArrayHasKey('lang', $result['items'][0]);
}
diff --git a/tests/Mf2/ParsePTest.php b/tests/Mf2/ParsePTest.php
index 6129ff0..7995236 100644
--- a/tests/Mf2/ParsePTest.php
+++ b/tests/Mf2/ParsePTest.php
@@ -1,5 +1,7 @@
Example User
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
@@ -32,11 +35,12 @@ public function testParsePHandlesInnerText() {
/**
* @group parseP
*/
- public function testParsePHandlesImg() {
+ public function testParsePHandlesImg(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
@@ -44,11 +48,12 @@ public function testParsePHandlesImg() {
/**
* @group parseP
*/
- public function testParsePHandlesAbbr() {
+ public function testParsePHandlesAbbr(): void {
$input = '@example';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
@@ -56,11 +61,12 @@ public function testParsePHandlesAbbr() {
/**
* @group parseP
*/
- public function testParsePHandlesData() {
+ public function testParsePHandlesData(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Example User', $output['items'][0]['properties']['name'][0]);
}
@@ -68,11 +74,12 @@ public function testParsePHandlesData() {
/**
* @group parseP
*/
- public function testParsePHandlesDataWithBlankValueAttribute() {
+ public function testParsePHandlesDataWithBlankValueAttribute(): void {
$input = 'Example User';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('', $output['items'][0]['properties']['name'][0]);
}
@@ -80,19 +87,21 @@ public function testParsePHandlesDataWithBlankValueAttribute() {
/**
* @group parseP
*/
- public function testParsePReturnsEmptyStringForBrHr() {
+ public function testParsePReturnsEmptyStringForBrHr(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('', $output['items'][0]['properties']['name'][0]);
$this->assertEquals('', $output['items'][0]['properties']['name'][0]);
}
- public function testParsesInputValue() {
+ public function testParsesInputValue(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('https://example.com', $result['items'][0]['properties']['url'][0]);
}
@@ -100,7 +109,7 @@ public function testParsesInputValue() {
* @see https://github.com/indieweb/php-mf2/issues/53
* @see https://microformats.org/wiki/microformats2-parsing#parsing_an_e-_property
*/
- public function testConvertsNestedImgElementToAltOrSrc() {
+ public function testConvertsNestedImgElementToAltOrSrc(): void {
$input = <<
The day I saw a 
@@ -108,6 +117,7 @@ public function testConvertsNestedImgElementToAltOrSrc() {
EOT;
$result = Mf2\parse($input, 'http://waterpigs.co.uk/articles/five-legged-elephant');
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('The day I saw a five legged elephant', $result['items'][0]['properties']['name'][0]);
$this->assertEquals('Blah blah http://waterpigs.co.uk/photos/five-legged-elephant.jpg', $result['items'][0]['properties']['summary'][0]);
}
@@ -115,10 +125,11 @@ public function testConvertsNestedImgElementToAltOrSrc() {
/**
* @see https://github.com/indieweb/php-mf2/issues/69
*/
- public function testBrWhitespaceIssue69() {
+ public function testBrWhitespaceIssue69(): void {
$input = 'Street Name 9
12345 NY, USA
';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('Street Name 9' . "\n" . '12345 NY, USA', $result['items'][0]['properties']['adr'][0]);
$this->assertEquals('Street Name 9', $result['items'][0]['properties']['street-address'][0]);
$this->assertEquals('12345 NY, USA', $result['items'][0]['properties']['locality'][0]);
@@ -130,10 +141,11 @@ public function testBrWhitespaceIssue69() {
/**
* @see https://github.com/indieweb/php-mf2/issues/89
*/
- public function testEmptyAlt() {
+ public function testEmptyAlt(): void {
$input = '';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('mention.tech', $result['items'][0]['properties']['org'][0]);
$this->assertEquals('mention.tech', $result['items'][0]['properties']['name'][0]);
}
diff --git a/tests/Mf2/ParseUTest.php b/tests/Mf2/ParseUTest.php
index 97a57a5..82335b8 100644
--- a/tests/Mf2/ParseUTest.php
+++ b/tests/Mf2/ParseUTest.php
@@ -1,4 +1,7 @@
Awesome example website';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com', $output['items'][0]['properties']['url'][0]);
}
@@ -30,11 +34,12 @@ public function testParseUHandlesA() {
/**
* @group parseU
*/
- public function testParseUHandlesEmptyHrefAttribute() {
+ public function testParseUHandlesEmptyHrefAttribute(): void {
$input = '';
$parser = new Parser($input, 'https://example.com/');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
}
@@ -42,11 +47,12 @@ public function testParseUHandlesEmptyHrefAttribute() {
/**
* @group parseU
*/
- public function testParseUHandlesMissingHrefAttribute() {
+ public function testParseUHandlesMissingHrefAttribute(): void {
$input = '';
$parser = new Parser($input, 'https://example.com/');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/Awesome example website', $output['items'][0]['properties']['url'][0]);
}
@@ -54,11 +60,12 @@ public function testParseUHandlesMissingHrefAttribute() {
/**
* @group parseU
*/
- public function testParseUHandlesImg() {
+ public function testParseUHandlesImg(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -66,11 +73,12 @@ public function testParseUHandlesImg() {
/**
* @group parseU
*/
- public function testParseUHandlesImgwithAlt() {
+ public function testParseUHandlesImgwithAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$result = array(
'value' => 'https://example.com/someimage.png',
@@ -82,11 +90,12 @@ public function testParseUHandlesImgwithAlt() {
/**
* @group parseU
*/
- public function testParseUHandlesImgwithoutAlt() {
+ public function testParseUHandlesImgwithoutAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals( 'https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -94,11 +103,12 @@ public function testParseUHandlesImgwithoutAlt() {
/**
* @group parseU
*/
- public function testParseUHandlesArea() {
+ public function testParseUHandlesArea(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -106,11 +116,12 @@ public function testParseUHandlesArea() {
/**
* @group parseU
*/
- public function testParseUHandlesObject() {
+ public function testParseUHandlesObject(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -118,11 +129,12 @@ public function testParseUHandlesObject() {
/**
* @group parseU
*/
- public function testParseUHandlesAbbr() {
+ public function testParseUHandlesAbbr(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -130,11 +142,12 @@ public function testParseUHandlesAbbr() {
/**
* @group parseU
*/
- public function testParseUHandlesAbbrNoTitle() {
+ public function testParseUHandlesAbbrNoTitle(): void {
$input = 'no title attribute';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('no title attribute', $output['items'][0]['properties']['photo'][0]);
}
@@ -142,11 +155,12 @@ public function testParseUHandlesAbbrNoTitle() {
/**
* @group parseU
*/
- public function testParseUHandlesData() {
+ public function testParseUHandlesData(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/someimage.png', $output['items'][0]['properties']['photo'][0]);
}
@@ -154,62 +168,68 @@ public function testParseUHandlesData() {
/**
* @group baseUrl
*/
- public function testResolvesRelativeUrlsFromDocumentUrl() {
+ public function testResolvesRelativeUrlsFromDocumentUrl(): void {
$input = '
';
$parser = new Parser($input, 'https://example.com/things/more/more.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/image.png', $output['items'][0]['properties']['photo'][0]);
}
/**
* @group baseUrl
*/
- public function testResolvesRelativeUrlsFromBaseUrl() {
+ public function testResolvesRelativeUrlsFromBaseUrl(): void {
$input = '
';
$parser = new Parser($input, 'https://example.com/things/more.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/more/image.png', $output['items'][0]['properties']['photo'][0]);
}
/**
* @group baseUrl
*/
- public function testResolvesRelativeUrlsInImpliedMicroformats() {
+ public function testResolvesRelativeUrlsInImpliedMicroformats(): void {
$input = '
';
$parser = new Parser($input, 'https://example.com/things/more.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/image.png', $output['items'][0]['properties']['photo'][0]);
}
/**
* @group baseUrl
*/
- public function testResolvesRelativeBaseRelativeUrlsInImpliedMicroformats() {
+ public function testResolvesRelativeBaseRelativeUrlsInImpliedMicroformats(): void {
$input = '
';
$parser = new Parser($input, 'https://example.com/');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/image.png', $output['items'][0]['properties']['photo'][0]);
}
/** @see https://github.com/indieweb/php-mf2/issues/33 */
- public function testParsesHrefBeforeValueClass() {
+ public function testParsesHrefBeforeValueClass(): void {
$input = 'WRONG';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('https://example.com/right', $result['items'][0]['properties']['url'][0]);
}
/**
* @group parseU
*/
- public function testParseUHandlesAudio() {
+ public function testParseUHandlesAudio(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('audio', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/audio.mp3', $output['items'][0]['properties']['audio'][0]);
}
@@ -217,11 +237,12 @@ public function testParseUHandlesAudio() {
/**
* @group parseU
*/
- public function testParseUHandlesVideo() {
+ public function testParseUHandlesVideo(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
}
@@ -229,11 +250,12 @@ public function testParseUHandlesVideo() {
/**
* @group parseU
*/
- public function testParseUHandlesVideoNoSrc() {
+ public function testParseUHandlesVideoNoSrc(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('no video support', $output['items'][0]['properties']['video'][0]);
}
@@ -241,11 +263,12 @@ public function testParseUHandlesVideoNoSrc() {
/**
* @group parseU
*/
- public function testParseUHandlesSource() {
+ public function testParseUHandlesSource(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
$this->assertEquals('https://example.com/video.ogg', $output['items'][0]['properties']['video'][1]);
@@ -254,11 +277,12 @@ public function testParseUHandlesSource() {
/**
* @group parseU
*/
- public function testParseUHandlesVideoPoster() {
+ public function testParseUHandlesVideoPoster(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
$this->assertEquals('https://example.com/posterimage.jpg', $output['items'][0]['properties']['photo'][0]);
@@ -267,11 +291,12 @@ public function testParseUHandlesVideoPoster() {
/**
* @group parseU
*/
- public function testParseUWithSpaces() {
+ public function testParseUWithSpaces(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com', $output['items'][0]['properties']['url'][0]);
}
@@ -279,7 +304,7 @@ public function testParseUWithSpaces() {
/**
* @see https://github.com/indieweb/php-mf2/issues/130
*/
- public function testImpliedUWithEmptyHref() {
+ public function testImpliedUWithEmptyHref(): void {
$input = 'Jane Doe
@@ -288,23 +313,28 @@ public function testImpliedUWithEmptyHref() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][1]['properties']);
$this->assertArrayHasKey('url', $output['items'][1]['properties']);
$this->assertEquals('https://example.com/', $output['items'][1]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][2]['properties']);
$this->assertArrayHasKey('url', $output['items'][2]['properties']);
$this->assertEquals('https://example.com/', $output['items'][2]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][3]['properties']);
$this->assertArrayHasKey('url', $output['items'][3]['properties']);
$this->assertEquals('https://example.com/', $output['items'][3]['properties']['url'][0]);
+ $this->assertArrayHasKey('children', $output['items'][4]);
$this->assertArrayHasKey('url', $output['items'][4]['children'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][4]['children'][0]['properties']['url'][0]);
}
- public function testValueFromLinkTag() {
+ public function testValueFromLinkTag(): void {
$input = <<< END
@@ -318,6 +348,8 @@ public function testValueFromLinkTag() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
+
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
@@ -325,10 +357,11 @@ public function testValueFromLinkTag() {
$this->assertEquals('Example.com homepage', $output['items'][0]['properties']['name'][0]);
}
- public function testResolveFromDataElement() {
+ public function testResolveFromDataElement(): void {
$parser = new Parser('', 'https://example.com/index.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/relative.html', $output['items'][0]['properties']['url'][0]);
}
@@ -336,7 +369,7 @@ public function testResolveFromDataElement() {
/**
* @see https://github.com/microformats/php-mf2/issues/182
*/
- public function testResolveFromIframeElement() {
+ public function testResolveFromIframeElement(): void {
$input = '
Title
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Name', $output['items'][0]['properties']['name'][0]);
}
- public function testValueClassTitleHandlesMultipleValueClass() {
+ public function testValueClassTitleHandlesMultipleValueClass(): void {
$input = 'Name (this should not be included) Endname
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('NameEndname', $output['items'][0]['properties']['name'][0]);
}
- public function testValueClassTitleHandlesSingleValueTitle() {
+ public function testValueClassTitleHandlesSingleValueTitle(): void {
$input = 'Wrong Name (this should not be included)
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Real Name', $output['items'][0]['properties']['name'][0]);
}
- public function testValueClassTitleHandlesMultipleValueTitle() {
+ public function testValueClassTitleHandlesMultipleValueTitle(): void {
$input = 'Wrong Name (this should not be included)
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('Real Name', $output['items'][0]['properties']['name'][0]);
}
@@ -55,7 +61,7 @@ public function testValueClassTitleHandlesMultipleValueTitle() {
/**
* @see https://github.com/indieweb/php-mf2/issues/25
*/
- public function testValueClassDatetimeWorksWithUrlProperties() {
+ public function testValueClassDatetimeWorksWithUrlProperties(): void {
$input = <<
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('published', $output['items'][0]['properties']);
$this->assertEquals('2013-06-27 10:17', $output['items'][0]['properties']['published'][0]);
}
@@ -77,7 +84,7 @@ class="dt-published published dt-updated updated u-url u-uid">
/**
* @see https://github.com/indieweb/php-mf2/issues/27
*/
- public function testParsesValueTitleDatetimes() {
+ public function testParsesValueTitleDatetimes(): void {
$input = <<
test
@@ -88,21 +95,25 @@ public function testParsesValueTitleDatetimes() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('2012-02-16T16:14:47+00:00', $output['items'][0]['properties']['published'][0]);
}
/** @see https://github.com/indieweb/php-mf2/issues/34 */
- public function testIgnoresValueClassNestedFurtherThanChild() {
+ public function testIgnoresValueClassNestedFurtherThanChild(): void {
$test = '12345678';
$result = Mf2\parse($test);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('1234', $result['items'][0]['properties']['tel'][0]);
+ $this->assertArrayHasKey('children', $result['items'][0]);
$this->assertEquals('5678', $result['items'][0]['children'][0]['properties']['tel'][0]);
}
/** @see https://github.com/indieweb/php-mf2/issues/38 */
- public function testValueClassDtMatchesSingleDigitTimeComponent() {
+ public function testValueClassDtMatchesSingleDigitTimeComponent(): void {
$test = ', ';
$result = Mf2\parse($test);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('2013-02-01 6:01', $result['items'][0]['properties']['published'][0]);
}
}
diff --git a/tests/Mf2/ParserTest.php b/tests/Mf2/ParserTest.php
index a6cd9d4..9c5aa7d 100644
--- a/tests/Mf2/ParserTest.php
+++ b/tests/Mf2/ParserTest.php
@@ -1,7 +1,11 @@
assertEquals('thing', Mf2\unicodeTrim(' thing '));
$this->assertEquals('thing', Mf2\unicodeTrim(' thing '));
- $this->assertEquals('thing', Mf2\unicodeTrim(mb_convert_encoding(' thing ', 'UTF-8', 'HTML-ENTITIES') ));
+ $entities = mb_convert_encoding(' thing ', 'UTF-8', 'HTML-ENTITIES');
+ \assert($entities !== false); // For PHPStan
+ $this->assertEquals('thing', Mf2\unicodeTrim($entities));
}
- public function testMicroformatNameFromClassReturnsFullRootName() {
+ public function testMicroformatNameFromClassReturnsFullRootName(): void {
$expected = array('h-card');
$actual = Mf2\mfNamesFromClass('someclass h-card someotherclass', 'h-');
$this->assertEquals($expected, $actual);
}
- public function testMicroformatNameFromClassHandlesMultipleHNames() {
+ public function testMicroformatNameFromClassHandlesMultipleHNames(): void {
$expected = array('h-card', 'h-person');
$actual = Mf2\mfNamesFromClass('someclass h-card someotherclass h-person yetanotherclass', 'h-');
$this->assertEquals($expected, $actual);
}
- public function testMicroformatStripsPrefixFromPropertyClassname() {
+ public function testMicroformatStripsPrefixFromPropertyClassname(): void {
$expected = array('name');
$actual = Mf2\mfNamesFromClass('someclass p-name someotherclass', 'p-');
$this->assertEquals($expected, $actual);
}
- public function testNestedMicroformatPropertyNameWorks() {
+ public function testNestedMicroformatPropertyNameWorks(): void {
$expected = array('location' => array('p-'), 'author' => array('u-', 'p-'));
$test = 'someclass p-location someotherclass u-author p-author';
$actual = Mf2\nestedMfPropertyNamesFromClass($test);
@@ -60,14 +66,14 @@ public function testNestedMicroformatPropertyNameWorks() {
$this->assertEqualsCanonicalizing($expected, $actual);
}
- public function testMicroformatNamesFromClassIgnoresPrefixesWithoutNames() {
+ public function testMicroformatNamesFromClassIgnoresPrefixesWithoutNames(): void {
$expected = array();
$actual = Mf2\mfNamesFromClass('someclass h- someotherclass', 'h-');
$this->assertEquals($expected, $actual);
}
- public function testMicroformatNamesFromClassHandlesExcessiveWhitespace() {
+ public function testMicroformatNamesFromClassHandlesExcessiveWhitespace(): void {
$expected = array('h-card');
$actual = Mf2\mfNamesFromClass(' someclass
h-card someotherclass ', 'h-');
@@ -75,54 +81,58 @@ public function testMicroformatNamesFromClassHandlesExcessiveWhitespace() {
$this->assertEquals($expected, $actual);
}
- public function testMicroformatNamesFromClassIgnoresUppercaseClassnames() {
+ public function testMicroformatNamesFromClassIgnoresUppercaseClassnames(): void {
$expected = array();
$actual = Mf2\mfNamesFromClass('H-ENTRY', 'h-');
$this->assertEquals($expected, $actual);
}
- public function testParseE() {
+ public function testParseE(): void {
$input = 'Here is a load of embedded markup';
//$parser = new Parser($input);
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertEquals('Here is a load of embedded markup', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('Here is a load of embedded markup', $output['items'][0]['properties']['content'][0]['value']);
}
- public function testParseEmptyE() {
+ public function testParseEmptyE(): void {
$input = 'Name ';
//$parser = new Parser($input);
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('Name', $output['items'][0]['properties']['name'][0]);
$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertEquals('', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('', $output['items'][0]['properties']['content'][0]['value']);
}
- public function testParseEResolvesRelativeLinks() {
+ public function testParseEResolvesRelativeLinks(): void {
$input = 'Blah blah thing. 
';
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('Blah blah thing.
', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('Blah blah thing. https://example.com/img', $output['items'][0]['properties']['content'][0]['value']);
}
- public function testParseEWithBR() {
+ public function testParseEWithBR(): void {
$input = 'Here is content with two lines.
The br tag should not be converted to an XML br/br element.';
//$parser = new Parser($input);
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertEquals('Here is content with two lines.
The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('Here is content with two lines.'."\n".'The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['value']);
}
- public function testParseEWithWhitespace() {
+ public function testParseEWithWhitespace(): void {
$input = '
This leading and trailing whitespace should be removed from the HTML and text values.
@@ -131,6 +141,7 @@ public function testParseEWithWhitespace() {
//$parser = new Parser($input);
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('content', $output['items'][0]['properties']);
$this->assertEquals('This leading and trailing whitespace should be removed from the HTML and text values.', $output['items'][0]['properties']['content'][0]['html']);
$this->assertEquals('This leading and trailing whitespace should be removed from the HTML and text values.', $output['items'][0]['properties']['content'][0]['value']);
@@ -139,7 +150,7 @@ public function testParseEWithWhitespace() {
/**
* @group parseH
*/
- public function testInvalidClassnamesContainingHAreIgnored() {
+ public function testInvalidClassnamesContainingHAreIgnored(): void {
$classname = 'asdfgh-jkl';
$input = sprintf('', $classname);
$parser = new Parser($input);
@@ -157,11 +168,11 @@ public function testInvalidClassnamesContainingHAreIgnored() {
$this->assertEquals(0, $matches, sprintf('Class name "%s" should not have parsed as a root microformat', $classname));
}
- public function testHtmlSpecialCharactersWorks() {
+ public function testHtmlSpecialCharactersWorks(): void {
$this->assertEquals('<>', htmlspecialchars('<>'));
}
- public function testHtmlEncodesNonEProperties() {
+ public function testHtmlEncodesNonEProperties(): void {
$input = '
<p>
<dt>
@@ -171,17 +182,19 @@ public function testHtmlEncodesNonEProperties() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('', $output['items'][0]['properties']['name'][0]);
$this->assertEquals('
', $output['items'][0]['properties']['published'][0]);
$this->assertEquals('', $output['items'][0]['properties']['url'][0]);
}
- public function testHtmlEncodesImpliedProperties() {
+ public function testHtmlEncodesImpliedProperties(): void {
$input = '
<name>';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('', $output['items'][0]['properties']['name'][0]);
$this->assertEquals('', $output['items'][0]['properties']['url'][0]);
$result = [
@@ -191,17 +204,17 @@ public function testHtmlEncodesImpliedProperties() {
$this->assertEquals($result, $output['items'][0]['properties']['photo'][0]);
}
- public function testParsesRelValues() {
+ public function testParsesRelValues(): void {
$input = 'Mr. Author';
$parser = new Parser($input);
$output = $parser->parse();
- $this->assertArrayHasKey('rels', $output);
+ $this->assertIsArray($output['rels']);
$this->assertEquals('https://example.com', $output['rels']['author'][0]);
}
- public function testParsesRelAlternateValues() {
+ public function testParsesRelAlternateValues(): void {
$input = 'German Homepage';
$parser = new Parser($input);
$parser->enableAlternates = true;
@@ -210,14 +223,19 @@ public function testParsesRelAlternateValues() {
$this->assertArrayHasKey('alternates', $output);
$this->assertEquals('https://example.com', $output['alternates'][0]['url']);
$this->assertEquals('home', $output['alternates'][0]['rel']);
+ $this->assertArrayHasKey('hreflang', $output['alternates'][0]);
$this->assertEquals('de', $output['alternates'][0]['hreflang']);
+ $this->assertArrayHasKey('media', $output['alternates'][0]);
$this->assertEquals('screen', $output['alternates'][0]['media']);
+ $this->assertArrayHasKey('type', $output['alternates'][0]);
$this->assertEquals('text/html', $output['alternates'][0]['type']);
+ $this->assertArrayHasKey('title', $output['alternates'][0]);
$this->assertEquals('German Homepage Link', $output['alternates'][0]['title']);
+ $this->assertArrayHasKey('text', $output['alternates'][0]);
$this->assertEquals('German Homepage', $output['alternates'][0]['text']);
}
- public function testParseFromIdOnlyReturnsMicroformatsWithinThatId() {
+ public function testParseFromIdOnlyReturnsMicroformatsWithinThatId(): void {
$input = <<Not Included
@@ -232,13 +250,14 @@ public function testParseFromIdOnlyReturnsMicroformatsWithinThatId() {
$output = $parser->parseFromId('parse-here');
$this->assertCount(1, $output['items']);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('Included', $output['items'][0]['properties']['name'][0]);
}
/**
* Issue #21 github.com/indieweb/php-mf2/issues/21
*/
- public function testDoesntAddArraysWithOnlyValueForAlreadyParsedNestedMicroformats() {
+ public function testDoesntAddArraysWithOnlyValueForAlreadyParsedNestedMicroformats(): void {
$input = <<
EOT;
$result = Mf2\parse($input, 'http://waterpigs.co.uk/articles/five-legged-elephant');
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('It is a strange thing to see a five legged elephant', $result['items'][0]['properties']['content'][0]['value']);
}
// parser not respecting not[h-*] in rule "else if .h-x>a[href]:only-of-type:not[.h-*] then use that [href] for url"
- public function testNotImpliedUrlFromHCard() {
+ public function testNotImpliedUrlFromHCard(): void {
$input = <<
John Q
@@ -324,10 +372,11 @@ public function testNotImpliedUrlFromHCard() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('url', $output['items'][0]['properties']);
}
- public function testAreaTag() {
+ public function testAreaTag(): void {
$input = <<
@@ -339,13 +388,14 @@ public function testAreaTag() {
// p-name is no longer implied for this test due to nested microformat
// see https://github.com/microformats/microformats2-parsing/issues/6
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']);
$this->assertEquals('rect', $output['items'][0]['properties']['category'][0]['shape']);
$this->assertEquals('100,100,120,120', $output['items'][0]['properties']['category'][0]['coords']);
$this->assertEquals('Person Bee', $output['items'][0]['properties']['category'][0]['value']);
}
- public function testParseHcardInCategory() {
+ public function testParseHcardInCategory(): void {
$input = <<
Alice tagged
@@ -360,6 +410,7 @@ public function testParseHcardInCategory() {
$output = $parser->parse();
$this->assertContains('h-entry', $output['items'][0]['type']);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('category', $output['items'][0]['properties']);
$this->assertContains('h-card', $output['items'][0]['properties']['category'][0]['type']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']['category'][0]['properties']);
@@ -368,8 +419,8 @@ public function testParseHcardInCategory() {
$this->assertEquals('http://b.example.com/', $output['items'][0]['properties']['category'][0]['properties']['url'][0]);
}
- public function testApplyTransformationToSrcset() {
- $transformation = function ($url) {
+ public function testApplyTransformationToSrcset(): void {
+ $transformation = function ($url): string {
return 'https://example.com/' . ltrim($url, '/');
};
@@ -382,25 +433,36 @@ public function testApplyTransformationToSrcset() {
/**
* @see https://github.com/indieweb/php-mf2/issues/84
- * @group internet
- *
- * 2024-04-07: The final photo URL in this test changed over time.
- * Updated it to only check that the final URL's hostname was correct,
- * not the full photo URL.
*/
- public function testRelativeURLResolvedWithFinalURL() {
- $mf = Mf2\fetch('http://aaron.pk/4Zn5');
+ public function testRelativeURLResolvedWithFinalURL(): void {
+ $server = new MockWebServer();
+ $server->start();
+
+ $body = file_get_contents(__DIR__ . '/aaron.pk_4Zn5.html');
+ \assert($body !== false); // For PHPStan
+
+ // Obtained from http://aaron.pk/4Zn5
+ $url = $server->setResponseOfPath(
+ '/4Zn5',
+ new MockWebServerResponse($body, [], 200)
+ );
+ \assert($url !== ''); // For PHPStan
+
+ $mf = Mf2\fetch($url);
+
+ $server->stop();
+
+ $this->assertIsArray($mf['items'][0]['properties']);
$this->assertArrayHasKey('photo', $mf['items'][0]['properties']);
$hostname = parse_url($mf['items'][0]['properties']['photo'][0], PHP_URL_HOST);
- $this->assertEquals('aaronparecki.com', $hostname);
+ $this->assertEquals('127.0.0.1', $hostname);
- // previous assertion: not the photo URL changed over time
- // $this->assertEquals('https://aaronparecki.com/img/1240x0/2014/12/23/5/photo.jpeg', $mf['items'][0]['properties']['photo'][0]);
+ $this->assertEquals($server->getServerRoot() . '/img/1240x,q60/2014/12/23/5/photo.jpeg', $mf['items'][0]['properties']['photo'][0]);
}
- public function testScriptTagContentsRemovedFromTextValue() {
+ public function testScriptTagContentsRemovedFromTextValue(): void {
$input = <<
@@ -413,6 +475,7 @@ public function testScriptTagContentsRemovedFromTextValue() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertContains('h-entry', $output['items'][0]['type']);
$this->assertStringContainsString(
'Hello World',
@@ -421,7 +484,7 @@ public function testScriptTagContentsRemovedFromTextValue() {
$this->assertStringNotContainsString('alert', $output['items'][0]['properties']['content'][0]);
}
- public function testScriptElementContentsRemovedFromAllPlaintextValues() {
+ public function testScriptElementContentsRemovedFromAllPlaintextValues(): void {
$input = <<
contained
@@ -432,11 +495,12 @@ public function testScriptElementContentsRemovedFromAllPlaintextValues() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertStringNotContainsString('not contained', $output['items'][0]['properties']['published'][0]);
$this->assertStringNotContainsString('not contained', $output['items'][0]['properties']['url'][0]);
}
- public function testScriptTagContentsNotRemovedFromHTMLValue() {
+ public function testScriptTagContentsNotRemovedFromHTMLValue(): void {
$input = <<
@@ -455,6 +519,7 @@ public function testScriptTagContentsNotRemovedFromHTMLValue() {
$output = $parser->parse();
$this->assertContains('h-entry', $output['items'][0]['type']);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertStringContainsString('Hello World', $output['items'][0]['properties']['content'][0]['value']);
$this->assertStringContainsString('Hello World', $output['items'][0]['properties']['content'][0]['html']);
# The script and style tags should be removed from plaintext results but left in HTML results.
@@ -464,7 +529,7 @@ public function testScriptTagContentsNotRemovedFromHTMLValue() {
$this->assertStringNotContainsString('visibility', $output['items'][0]['properties']['content'][0]['value']);
}
- public function testWhitespaceBetweenElements() {
+ public function testWhitespaceBetweenElements(): void {
$input = <<
I'm attending
@@ -479,6 +544,7 @@ public function testWhitespaceBetweenElements() {
$this->assertContains('h-entry', $output['items'][0]['type']);
// p-name is no longer implied for this test due to other p-*
// see https://github.com/microformats/microformats2-parsing/issues/6
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']);
}
@@ -486,7 +552,7 @@ public function testWhitespaceBetweenElements() {
/**
* @see http://www.kevinmarks.com/twitterutils.html
*/
- public function testCamelCaseClassNames() {
+ public function testCamelCaseClassNames(): void {
$input = <<
@@ -546,6 +612,7 @@ public function testCamelCaseClassNames() {
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('linkBlend', $output['items'][0]['properties']);
$this->assertArrayNotHasKey('hiddenInNarrowEnv', $output['items'][0]['properties']);
$this->assertArrayNotHasKey('floatRight', $output['items'][0]['properties']);
@@ -555,7 +622,7 @@ public function testCamelCaseClassNames() {
/**
* @see https://github.com/indieweb/php-mf2/issues/127
*/
- public function testCamelCaseRootClassNames() {
+ public function testCamelCaseRootClassNames(): void {
$input = '';
$output = Mf2\parse($input);
@@ -566,7 +633,7 @@ public function testCamelCaseRootClassNames() {
/**
* @see https://github.com/indieweb/php-mf2/issues/127
*/
- public function testMisTypedRootClassNames() {
+ public function testMisTypedRootClassNames(): void {
$input = '
@@ -577,17 +644,18 @@ public function testMisTypedRootClassNames() {
$this->assertEmpty($output['items']);
}
- public function testClassNameNumbers() {
+ public function testClassNameNumbers(): void {
$input = ' Test
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('column1', $output['items'][0]['properties']);
}
/**
* @see https://github.com/microformats/microformats2-parsing/issues/6#issuecomment-366473390
*/
- public function testNoImpliedNameWhenE()
+ public function testNoImpliedNameWhenE(): void
{
$input = '
@@ -599,13 +667,14 @@ public function testNoImpliedNameWhenE()
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']);
}
/**
* @see https://github.com/microformats/microformats2-parsing/issues/6#issuecomment-366473390
*/
- public function testNoImpliedNameWhenP()
+ public function testNoImpliedNameWhenP(): void
{
$input = '
@@ -617,13 +686,14 @@ public function testNoImpliedNameWhenP()
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']);
}
/**
* @see https://github.com/microformats/microformats2-parsing/issues/6#issuecomment-366473390
*/
- public function testNoImpliedNameWhenNestedMicroformat()
+ public function testNoImpliedNameWhenNestedMicroformat(): void
{
$input = '
@@ -635,13 +705,14 @@ public function testNoImpliedNameWhenNestedMicroformat()
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayNotHasKey('name', $output['items'][0]['properties']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/143
*/
- public function testChildObjects() {
+ public function testChildObjects(): void {
$input = <<
@@ -673,8 +744,10 @@ public function testChildObjects() {
END;
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('author', $output['items'][0]['properties']);
$this->assertEquals('Author Name', $output['items'][0]['properties']['author'][0]['properties']['name'][0]);
+ $this->assertArrayHasKey('children', $output['items'][0]);
$this->assertCount(4, $output['items'][0]['children']);
$this->assertEquals('One', $output['items'][0]['children'][0]['properties']['name'][0]);
$this->assertEquals('Two', $output['items'][0]['children'][1]['properties']['name'][0]);
@@ -683,7 +756,7 @@ public function testChildObjects() {
}
- public function testMultiLevelRecursion() {
+ public function testMultiLevelRecursion(): void {
$input = <<
@@ -723,8 +796,10 @@ public function testMultiLevelRecursion() {
END;
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('author', $output['items'][0]['properties']);
$this->assertEquals('Author Name', $output['items'][0]['properties']['author'][0]['properties']['name'][0]);
+ $this->assertArrayHasKey('children', $output['items'][0]);
$this->assertCount(4, $output['items'][0]['children']);
$this->assertEquals('One', $output['items'][0]['children'][0]['properties']['name'][0]);
$this->assertEquals('Two', $output['items'][0]['children'][1]['properties']['name'][0]);
@@ -737,17 +812,18 @@ public function testMultiLevelRecursion() {
$this->assertEquals('Four', $output['items'][0]['children'][3]['properties']['name'][0]);
}
- public function testNoErrantWhitespaceOnEHtml()
+ public function testNoErrantWhitespaceOnEHtml(): void
{
$input = '1
2
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('1
2
', $output['items'][0]['properties']['content'][0]['html']);
}
/**
* @see https://github.com/indieweb/php-mf2/issues/158
*/
- public function testPrefixWithNumbers() {
+ public function testPrefixWithNumbers(): void {
$input = '
@@ -756,6 +832,7 @@ public function testPrefixWithNumbers() {
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('p3k-drank', $output['items'][0]['properties']);
$this->assertCount(1, $output['items'][0]['properties']['p3k-drank']);
$this->assertEquals('h-p3k-food', $output['items'][0]['properties']['p3k-drank'][0]['type'][0]);
@@ -764,7 +841,7 @@ public function testPrefixWithNumbers() {
/**
* @see https://github.com/indieweb/php-mf2/issues/160
*/
- public function testConsecutiveDashes() {
+ public function testConsecutiveDashes(): void {
$input = '
Too many dashes
@@ -776,6 +853,7 @@ public function testConsecutiveDashes() {
$this->assertCount(1, $output['items'][0]['type']);
$this->assertEquals('h-entry', $output['items'][0]['type'][0]);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertCount(1, $output['items'][0]['properties']);
$this->assertArrayHasKey('name', $output['items'][0]['properties']);
}
@@ -787,7 +865,7 @@ public function testConsecutiveDashes() {
* @see https://github.com/indieweb/php-mf2/issues/160
* @see https://github.com/indieweb/php-mf2/issues/158
*/
- public function testMfClassRegex() {
+ public function testMfClassRegex(): void {
$input = '
URL
name
@@ -798,6 +876,7 @@ public function testMfClassRegex() {
$this->assertContains('h-feed', $output['items'][0]['type']);
$this->assertContains('h-p3k-entry', $output['items'][0]['type']);
$this->assertContains('h-x-test', $output['items'][0]['type']);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertCount(5, $output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertArrayHasKey('p3k-url', $output['items'][0]['properties']);
@@ -809,7 +888,7 @@ public function testMfClassRegex() {
/**
* @see https://github.com/microformats/microformats2-parsing/issues/30
*/
- public function testUniqueAndAlphabeticalMfClasses() {
+ public function testUniqueAndAlphabeticalMfClasses(): void {
$input = '';
$output = Mf2\parse($input);
@@ -820,13 +899,14 @@ public function testUniqueAndAlphabeticalMfClasses() {
* The default DOMDocument parser will trip here because it does not know HTML5 elements.
* @see https://html.spec.whatwg.org/#optional-tags:the-p-element
**/
- public function testHtml5OptionalPEndTag() {
+ public function testHtml5OptionalPEndTag(): void {
if (!class_exists('Masterminds\\HTML5')) {
$this->markTestSkipped('masterminds/html5 is required for this test.');
}
$input = 'NameNot Name
';
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('Name', $output['items'][0]['properties']['name'][0]);
}
@@ -835,8 +915,9 @@ public function testHtml5OptionalPEndTag() {
* @see https://github.com/indieweb/php-mf2/issues/174
* @see https://github.com/microformats/mf2py/issues/104
*/
- public function testNotMutatingPassedInDOM() {
+ public function testNotMutatingPassedInDOM(): void {
$input = file_get_contents(__DIR__ . '/snarfed.org.html');
+ \assert($input !== false); // For PHPStan.
// Use same parsing as Parser::__construct(), twice to have a comparison object.
libxml_use_internal_errors(true);
@@ -853,7 +934,7 @@ public function testNotMutatingPassedInDOM() {
$this->assertEquals($refDoc, $inputDoc, 'Parsing mutated the DOMDocument.');
}
- public function testNoImpliedURLForEmptyProperties() {
+ public function testNoImpliedURLForEmptyProperties(): void {
// In the 0.4.5 release, this caused an error
// https://github.com/microformats/php-mf2/issues/196
@@ -866,6 +947,7 @@ public function testNoImpliedURLForEmptyProperties() {
EOD;
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertIsArray($output['items'][0]['properties']['comment'][0]['properties']);
$this->assertIsArray($output['items'][0]['properties']['comment'][0]['children'][0]['properties']);
$this->assertEmpty($output['items'][0]['properties']['comment'][0]['properties']);
@@ -876,7 +958,7 @@ public function testNoImpliedURLForEmptyProperties() {
* Make sure day of year passed to normalizeOrdinalDate() is valid
* @see https://github.com/indieweb/php-mf2/issues/167
*/
- public function testInvalidOrdinalDate() {
+ public function testInvalidOrdinalDate(): void {
# 365 days in non-leap years
$this->assertEquals('2018-12-31', Mf2\normalizeOrdinalDate('2018-365'));
$this->assertEquals('', Mf2\normalizeOrdinalDate('2018-366'));
@@ -888,7 +970,7 @@ public function testInvalidOrdinalDate() {
/**
* @see https://github.com/microformats/php-mf2/issues/230
*/
- public function testPropertyWithInvalidHPrefixedRootClassParsed() {
+ public function testPropertyWithInvalidHPrefixedRootClassParsed(): void {
$input = <<
@@ -896,10 +978,11 @@ public function testPropertyWithInvalidHPrefixedRootClassParsed() {
EOF;
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(array('value' => '/image.jpg', 'alt' => 'Jon Doe'), $output['items'][0]['properties']['photo'][0]);
}
- public function testGetRootMfOnlyFindsValidElements() {
+ public function testGetRootMfOnlyFindsValidElements(): void {
$input = << content
@@ -919,7 +1002,7 @@ public function testGetRootMfOnlyFindsValidElements() {
/**
* @see https://github.com/microformats/php-mf2/issues/245
*/
- public function testNewlineBeforePrefix() {
+ public function testNewlineBeforePrefix(): void {
$input = <<
@@ -959,7 +1043,7 @@ public function testInvalidRootsIgnored() {
/**
* @see https://github.com/microformats/php-mf2/issues/249
*/
- public function testInvalidNestedRootsIgnored() {
+ public function testInvalidNestedRootsIgnored(): void {
$input = <<
@@ -986,7 +1070,7 @@ public function testInvalidNestedRootsIgnored() {
/**
* @see https://github.com/microformats/php-mf2/issues/249
*/
- public function testInvalidNestedPropertiesIgnored1() {
+ public function testInvalidNestedPropertiesIgnored1(): void {
$input = <<
@@ -1000,6 +1084,7 @@ public function testInvalidNestedPropertiesIgnored1() {
$output = Mf2\parse($input);
# `properties` should be empty
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(0, count($output['items'][0]['properties']));
# `children` should have length=2
@@ -1014,7 +1099,7 @@ public function testInvalidNestedPropertiesIgnored1() {
/**
* @see https://github.com/microformats/php-mf2/issues/246
*/
- public function testInvalidNestedPropertiesIgnored2() {
+ public function testInvalidNestedPropertiesIgnored2(): void {
$input = <<
TITLE
@@ -1028,6 +1113,7 @@ public function testInvalidNestedPropertiesIgnored2() {
$output = Mf2\parse($input);
# `properties` should have length=3
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(3, count($output['items'][0]['properties']));
# should have these properties
diff --git a/tests/Mf2/PlainTextTest.php b/tests/Mf2/PlainTextTest.php
index 0bcdd3e..c78bb80 100644
--- a/tests/Mf2/PlainTextTest.php
+++ b/tests/Mf2/PlainTextTest.php
@@ -1,5 +1,7 @@
parse();
$entryProperties = $output['items'][0]['properties'];
+ $this->assertIsArray($entryProperties);
$this->assertEquals($pName, $entryProperties['name'][0]);
$this->assertEquals($eValue, $entryProperties['content'][0]['value']);
$this->assertEquals($eHtml, $entryProperties['content'][0]['html']);
}
- public function aaronpkExpectations() {
+ /**
+ * @return array
+ */
+ public function aaronpkExpectations(): array {
return array(
1 => array(
"\n Hello World
\n",
diff --git a/tests/Mf2/RelTest.php b/tests/Mf2/RelTest.php
index a4f1d32..86385a5 100644
--- a/tests/Mf2/RelTest.php
+++ b/tests/Mf2/RelTest.php
@@ -1,4 +1,7 @@
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOnATag() {
+ public function testRelValueOnATag(): void {
$input = 'webmention me';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOnAreaTag() {
+ public function testRelValueOnAreaTag(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOrder() {
+ public function testRelValueOrder(): void {
$input = '
webmention me
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][2]);
}
- public function testRelValueOrder2() {
+ public function testRelValueOrder2(): void {
$input = '
webmention me';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][2]);
}
- public function testRelValueOrder3() {
+ public function testRelValueOrder3(): void {
$input = '
@@ -76,21 +84,23 @@ public function testRelValueOrder3() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][2]);
}
- public function testRelValueOnBTag() {
+ public function testRelValueOnBTag(): void {
$input = 'this makes no sense';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayNotHasKey('webmention', $output['rels']);
}
- public function testEnableAlternatesFlagTrue() {
+ public function testEnableAlternatesFlagTrue(): void {
$input = 'author a
author b
post 1
@@ -106,7 +116,7 @@ public function testEnableAlternatesFlagTrue() {
$this->assertArrayHasKey('alternates', $output);
}
- public function testEnableAlternatesFlagFalse() {
+ public function testEnableAlternatesFlagFalse(): void {
$input = 'author a
author b
post 1
@@ -126,7 +136,7 @@ public function testEnableAlternatesFlagFalse() {
* @see https://github.com/indieweb/php-mf2/issues/112
* @see https://microformats.org/wiki/microformats2-parsing#rel_parse_examples
*/
- public function testRelURLs() {
+ public function testRelURLs(): void {
$input = 'author a
author b
post 1
@@ -139,14 +149,14 @@ public function testRelURLs() {
$parser = new Parser($input);
$output = $parser->parse();
- $this->assertArrayHasKey('rels', $output);
+ $this->assertIsArray($output['rels']);
$this->assertCount(4, $output['rels']);
$this->assertArrayHasKey('author', $output['rels']);
$this->assertArrayHasKey('in-reply-to', $output['rels']);
$this->assertArrayHasKey('alternate', $output['rels']);
$this->assertArrayHasKey('home', $output['rels']);
- $this->assertArrayHasKey('rel-urls', $output);
+ $this->assertIsArray($output['rel-urls']);
$this->assertCount(6, $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/a', $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/b', $output['rel-urls']);
@@ -155,18 +165,24 @@ public function testRelURLs() {
$this->assertArrayHasKey('https://example.com/fr', $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/articles.atom', $output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/a']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/a']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/a']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/b']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/b']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/b']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/1']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/1']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/1']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/2']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/2']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/2']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('media', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('hreflang', $output['rel-urls']['https://example.com/fr']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('title', $output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('type', $output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/articles.atom']);
@@ -176,42 +192,52 @@ public function testRelURLs() {
* @see https://github.com/microformats/microformats2-parsing/issues/29
* @see https://github.com/microformats/microformats2-parsing/issues/30
*/
- public function testRelURLsRelsUniqueAndSorted() {
+ public function testRelURLsRelsUniqueAndSorted(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['rels'], array('archived', 'bookmark', 'me'));
}
- public function testRelURLsInfoMergesCorrectly() {
+ public function testRelURLsInfoMergesCorrectly(): void {
$input = 'This nodeValue
Not this nodeValue';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#']);
+ $this->assertArrayHasKey('hreflang', $output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['hreflang'], 'en');
$this->assertArrayNotHasKey('media', $output['rel-urls']['#']);
$this->assertArrayNotHasKey('title', $output['rel-urls']['#']);
$this->assertArrayNotHasKey('type', $output['rel-urls']['#']);
+ $this->assertArrayHasKey('text', $output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['text'], 'This nodeValue');
}
- public function testRelURLsNoDuplicates() {
+ public function testRelURLsNoDuplicates(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertEquals($output['rels']['a'], array('#a', '#b'));
}
- public function testRelURLsFalsyTextVSEmpty() {
+ public function testRelURLsFalsyTextVSEmpty(): void {
$input = '0
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#a']);
$this->assertArrayHasKey('text', $output['rel-urls']['#a']);
$this->assertEquals($output['rel-urls']['#a']['text'], '0');
+ $this->assertIsArray($output['rel-urls']['#b']);
$this->assertArrayNotHasKey('text', $output['rel-urls']['#b']);
}
diff --git a/tests/Mf2/URLTest.php b/tests/Mf2/URLTest.php
index 2da4691..96efe82 100644
--- a/tests/Mf2/URLTest.php
+++ b/tests/Mf2/URLTest.php
@@ -1,5 +1,7 @@
assertEquals('one/two', $input);
@@ -25,7 +27,7 @@ public function testRemoveLeadingDotSlash() {
$this->assertEquals('one/two', $input);
}
- public function testRemoveLeadingSlashDot() {
+ public function testRemoveLeadingSlashDot(): void {
$input = '/./one/two';
mf2\removeLeadingSlashDot($input);
$this->assertEquals('/one/two', $input);
@@ -43,7 +45,7 @@ public function testRemoveLeadingSlashDot() {
$this->assertEquals('/../../g', $input);
}
- public function testRemoveOneDirLevel() {
+ public function testRemoveOneDirLevel(): void {
$input = '/../../g';
$output = '/a/b/c';
mf2\removeOneDirLevel($input, $output);
@@ -57,7 +59,7 @@ public function testRemoveOneDirLevel() {
$this->assertEquals('/a/b', $output);
}
- public function testRemoveLoneDotDot() {
+ public function testRemoveLoneDotDot(): void {
$input = '.';
mf2\removeLoneDotDot($input);
$this->assertEquals('', $input);
@@ -67,7 +69,7 @@ public function testRemoveLoneDotDot() {
$this->assertEquals('', $input);
}
- public function testMoveOneSegmentFromInput() {
+ public function testMoveOneSegmentFromInput(): void {
$input = '/a/b/c/./../../g';
$output = '';
mf2\moveOneSegmentFromInput($input, $output);
@@ -96,12 +98,15 @@ public function testMoveOneSegmentFromInput() {
/**
* @dataProvider removeDotSegmentsData
*/
- public function testRemoveDotSegments($assert, $path, $expected) {
+ public function testRemoveDotSegments(string $assert, string $path, string $expected): void {
$actual = mf2\removeDotSegments($path);
$this->assertEquals($expected, $actual, $assert);
}
- public function removeDotSegmentsData() {
+ /**
+ * @return list
+ */
+ public function removeDotSegmentsData(): array {
return array(
array('Should remove .. and .',
'/a/b/c/./../../g', '/a/g'),
@@ -109,11 +114,13 @@ public function removeDotSegmentsData() {
'/a/b/c/d/../../../g', '/a/g'),
array('Should not add leading slash',
'a/b/c', 'a/b/c'),
+ array('Should remove extra ..',
+ '/a/b/../../../..', '/'),
);
}
- public function testNoPathOnBase() {
+ public function testNoPathOnBase(): void {
$actual = mf2\resolveUrl('https://example.com', '');
$this->assertEquals('https://example.com/', $actual);
@@ -124,7 +131,7 @@ public function testNoPathOnBase() {
$this->assertEquals('https://example.com/#thing', $actual);
}
- public function testMisc() {
+ public function testMisc(): void {
$expected = 'http://a/b/c/g';
$actual = mf2\resolveUrl('http://a/b/c/d;p?q', './g');
$this->assertEquals($expected, $actual);
@@ -139,7 +146,7 @@ public function testMisc() {
}
/** as per https://github.com/indieweb/php-mf2/issues/35 */
- public function testResolvesProtocolRelativeUrlsCorrectly() {
+ public function testResolvesProtocolRelativeUrlsCorrectly(): void {
$expected = 'https://cdn.example.com/thing/asset.css';
$actual = Mf2\resolveUrl('https://example.com', '//cdn.example.com/thing/asset.css');
$this->assertEquals($expected, $actual);
@@ -152,13 +159,16 @@ public function testResolvesProtocolRelativeUrlsCorrectly() {
/**
* @dataProvider dataProvider
*/
- public function testReturnsUrlIfAbsolute($assert, $base, $url, $expected) {
+ public function testReturnsUrlIfAbsolute(string $assert, string $base, string $url, string $expected): void {
$actual = mf2\resolveUrl($base, $url);
$this->assertEquals($expected, $actual, $assert);
}
- public function dataProvider() {
+ /**
+ * @return list
+ */
+ public function dataProvider(): array {
// seriously, please update to PHP 5.4 so I can use nice array syntax ;)
// fail message, base, url, expected
$cases = array(
@@ -253,14 +263,8 @@ public function dataProvider() {
);
- // PHP 5.4 and before returns a different result, but either are acceptable
- if(PHP_MAJOR_VERSION <= 5 && PHP_MINOR_VERSION <= 4) {
- $cases[] = array('relative add scheme host user from base',
- 'http://user:@www.example.com', 'server.php', 'http://user@www.example.com/server.php');
- } else {
- $cases[] = array('relative add scheme host user from base',
- 'http://user:@www.example.com', 'server.php', 'http://user:@www.example.com/server.php');
- }
+ $cases[] = array('relative add scheme host user from base',
+ 'http://user:@www.example.com', 'server.php', 'http://user:@www.example.com/server.php');
// Test cases from RFC
// http://tools.ietf.org/html/rfc3986#section-5.4
diff --git a/tests/Mf2/aaron.pk_4Zn5.html b/tests/Mf2/aaron.pk_4Zn5.html
new file mode 100644
index 0000000..38b8d7c
--- /dev/null
+++ b/tests/Mf2/aaron.pk_4Zn5.html
@@ -0,0 +1,426 @@
+
+
+
+
+
+ SFO ✈️ SLC ✈️ PDX #travel • Aaron Parecki
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WeChat ID
aaronpk_tv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Mf2/bootstrap.php b/tests/Mf2/bootstrap.php
index db629b3..8c60253 100644
--- a/tests/Mf2/bootstrap.php
+++ b/tests/Mf2/bootstrap.php
@@ -1,3 +1,5 @@
+
+
+
+
+
+
+
+
+
+
+
+ Barnaby Walters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ New corollary to the 2010s classic snarky programmer adage “the cloud is someone else’s computer”:
+
+“AI is someone else’s GPU”
+
+from which it follows that
+
+“I’m starting a new company with AI someone else’s GPU”
+
+“I spent hours talking to AI someone else’s GPU about my life and the AI someone else’s GPU told me to break up with my boyfriend”
+
+“I’m worried that my job is in danger of being replaced by AI someone else’s GPU“
+
+“It’s crazy what convincing images AI someone else’s GPU can generate these days!” (okay, that one doesn’t sound so far-fetched)
+
+“Users expect our product to have advanced features and integration with AI someone else’s GPU”
+
+“AI someone else’s GPU is the defining technology of the decade, if not the century”
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ Here’s a KDE Plasma service menu (dolphin context menu action) for creating a valid CACHEDIR.TAG file in the selected folder. Useful for excluding things from being backed up! (e.g. via restic with the --exclude-caches option)
+
+[Desktop Entry]
+Type=Service
+MimeType=inode/directory
+Actions=create_cachedir_tag
+
+[Desktop Action create_cachedir_tag]
+Name=Create CACHEDIR.TAG
+Icon=breeze/actions/22/document-edit-encrypt
+Exec=echo "Signature: 8a477f597d28d172789f06886806bc55" > %u/CACHEDIR.TAG
+
+
+Put it somewhere like .local/share/kio/servicemenus/cachedir-tag.desktop, make it executable and it should show up in your context menu.
+
+
+
+
+
+
+ -
+
+
+
+
+
+ At the time of writing, due to a packaging mess-up, the builds of SDR++ (and many other SDR tools by the looks of it) have suddenly and unintentionally dropped support for the popular RTL-SDR software defined radio dongle. Until this is fixed, users will have to build these applications themselves. The instructions are a little lacking in details, so here’s exactly how to do that, working on Kubuntu:
+
+
+# To install:
+sudo aptitude install cmake libfftw3-dev libglfw3-dev libvolk-dev zstd libairspy-dev librtlsdr-dev
+git clone https://github.com/AlexandreRouma/SDRPlusPlus.git
+cd SDRPlusPlus
+mkdir build
+cd build
+cmake ..
+make -j5 # 5 is the number of threads to use for building. adjust to your preference
+sh ../create_root.sh
+sudo make install
+
+# To run:
+sdrpp
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Reddit recently underwent another new, unpopular redesign, meaning that there are now three different UIs for accessing the website. Out of habit I would look at new-new reddit before remembering to switch to old-new reddit, and quickly noticed that looking at new-new reddit causes my laptop’s fans instantly start spinning.
+
+Here’s a firefox performance profile for 20-30s of each iteration of the reddit homepage. I simply loaded the page and did absolutely nothing.
+
+old.reddit.com: constant ~5% CPU usage with occasional spikes up to ~90%
+
+
+
+new.reddit.com: usually 0% CPU usage with occasional bursts up to ~50%
+
+
+
+reddit.com (new-new reddit): constant 30% CPU usage with occasional spikes even higher
+
+
+
+I don’t have the time or knowledge required to dig into the performance profiler but I would be fascinated to know how old-new reddit ended up more efficient than old-old reddit, and exactly what new-new reddit is doing with 30% of my CPU??
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ When importing photos into DigiKam, I want them to be renamed based on the ISO8601 datetime they were taken, ideally to millisecond precision to avoid conflicts when multiple images were taken in a single second. This has the nice side-effect that photos from multiple camera sources are guaranteed to be displayed in the correct order when browsing files, which is important and practical for me.
+
+I started out using this custom file renaming template on import:
+
+[date:"yyyy-MM-ddTHHMMss"]-[file]
+
+
+as DigiKam’s [date] placeholder didn’t have an option for milliseconds, and I couldn‘t find a counter option which could handle my desired “append -# per-collision if this renaming scheme results in collisions”, so ended up just adding the entire camera-generated filename to the end.
+
+Unfortunately, this led to my files all being in the wrong order, even from the same camera. I haven’t quite figured out why, but it seems that there are several different internal datetime values stored in the image files: file creation date (which is completely wrong), the values used in DigiKam’s [date] templates (which are mostly wrong), and the DateTimeOriginal values stored in Exif data, which are not only correct but provide sub-second resolution too!
+
+So here’s the DigiKam import naming template which I will be using going forward:
+
+[meta:Exif.Photo.DateTimeOriginal]{range:1,10}{replace:":","-"}T[meta:Exif.Photo.DateTimeOriginal]{range:12,}{replace:":",""}s[meta:Exif.Photo.SubSecTimeOriginal]
+
+
+which produces ISO8601-ish filenames like this:
+
+2023-06-16T143139s922.JPG
+
+
+Broken down,
+
+[meta:Exif.Photo.DateTimeOriginal]
+
+
+evalulates to a string like
+
+2023:06:16 14:31:39
+
+
+but I don’t want colons in filenames for portability, so I take only the date part with {range:1,10}, replace the colons with hyphens {replace:":","-"}, add a literal T separator to avoid spaces in filenames, take the time part of the datetime and remove the colons completely, add a literal s separator to delimit seconds and milliseconds as I wanted to keep them separate but not use the typical . delimiter.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Ended up getting frustrated with the old version of DigiKam available on Kubuntu, so tried installing an AppImage. The state of AppImage integration with Kubuntu is abysmal, and I open DigiKam fairly regularly, so I finally tried installing AppImageLauncher, which is recommended by DigiKam and is supposed to be a good tool for integrating AppImages with the desktop environment (something which Plasma should surely do itself, if AppImages are really going to be part of the future of linux app packaging).
+
+Unfortunately, installing AppImageLauncher completely broke my desktop environment, causing it to hang and preventing me from logging in. Looked it up and it was clearly related to whatever this issue is about, as moving .local/share/mime fixed it. Removing AppImageLauncher and the mime cache got things working again, and, lo, before it broke my system, AppImageLauncher had kindly made .desktop files for all my AppImages!
+
+At this point I decided to take a more manual approach to integrating AppImages I cared about with my DE, so I added a link from ~/Applications (where I store AppImages and other applications not installed via the package manager) to ~/.local/share/applications, where .desktop files are kept. Having quick access to this location makes manually managing .desktop files much more bearable, and I went about improving the ones AppImageLauncher had made (e.g. adding version numbers to the names – I find it very useful to know what version of an app I’m launching).
+
+So, back to DigiKam: at this point I had a DigiKam 8.3 AppImage installed and openable via launchers thanks to the .desktop file. It had to re-download the facial recognition files, but other than that picked up everything from before. However, in the main photo list view, the maximum size of the thumbnails was tiny.
+
+I spent some time poking around in settings and tweaking the QT scaling factor via the .desktop file, but I’ll spare you the details. tl;dr: if you want the DigiKam 8.3 AppImage to let you see large thumbnails on a high-DPI screen, you need to check the following boxes:
+
+
+- Miscellaneous → System → Use high DPI scaling from the screen factor
+- Vews → Icons → Use large thumbnail size for high screen resolution
+
+
+Restart DigiKam, and it should let you make thumbnails large enough to be useful. This is especially necessary seeing as how DigiKam’s photo list view has a horribly wasteful layout, with almost as much whitespace as photo surface area.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you run into weird “file corrupt or unwritable” errors when trying to tag/rename tracks with Picard on (k)ubuntu, check whether the files are read-only. When using Dolphin to rip and encode CDs (an excellent feature – Dolphin continues to surprise me) it retains their read-only permissions when copying them to your disk, rather than setting it to something sensible.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Drew ferris with a soldering iron as I couldn‘t find much embedded rust art
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Some tips for using Teensy on linux:
+
+The teensy board support package is only supported in the Arduino applications downloaded directly from the arduino site, NOT on versions distributed by package managers. I used the AppImage and it worked fine. If you try to install the teensy board package on an unsupported version of Arduino you might see errors like “archive not supported”.
+
+Even when you have a supported version of Arduino installed, installing the Teensy board package isn’t totally reliable. The first time I downloaded it, compiling would fail with the following error:
+
+fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory
+
+Compilation error: fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory
+
+
+The 11.3.1 folder existed, but was empty. Down- then upgrading the board package didn‘t fix it. Removing the board package and reinstalling it did work.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you’re getting the following error in Inkscape on (k)ubuntu when trying to open the Extension Manager:
+
+[long traceback snipped]
+ModuleNotFoundError: No module named 'appdirs'
+
+
+the best way to deal with it seems to be sudo apt install python3-appdirs, as trying to install the appdirs module with pip or pip3 might not put it in the right place for the system python3 which inkscape is using, especially if you use something like conda or pyenv.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ In a world where even “digital-natives” increasingly don’t understand basic file management, and where it’s more and more common for user data to be siloed per-app even on desktops, I propose a corollary to Zawinski’s Law: “All apps which don’t store data transparently in the file system are doomed to implement their own limited and fragile filesystem equivalent”
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you’re in the unfortunate position of needing to use MuseScore4 on linux for some reason (for example to use its excellent MIDI to notation conversion) and are having issues with the Flatpak version having an unreadably tiny UI on high-DPI screens, here’s how to fix it.
+
+Open the .desktop file for MuseScore 4 – mine was in /var/lib/flatpak/app/org.musescore.MuseScore/current/active/export/share/applications/org.musescore.MuseScore.desktop
+
+Find the Exec key, and change the command to include --env=QT_SCALE_FACTOR=2. Mine ended up looking like this:
+
+Exec=/usr/bin/flatpak run --env=QT_SCALE_FACTOR=2 --branch=stable --arch=x86_64 --command=mscore --file-forwarding org.musescore.MuseScore @@ %F @@
+
+
+Save (you’ll need to enter your password, or to have launched the editor with sudo).
+
+Try launching MuseScore again. If you’re lucky, it’ll have a readable UI. If not, try restarting and launching it again — I haven’t found a way of successfully getting KDE to force-update all its .desktop files. Presumably there’s a cache somewhere? If anyone knows how to reliably do this, please let me know!
+
+
+This should work for any Flatpak which uses QT, on any desktop environment which uses .desktop files. I really hope “UI Scale” becomes a standard per-application setting in the near future.
+
+EDIT: thanks to carmanaught on the KDE forums for this additional suggestion to copy the .desktop file to ~/.local/share/applications rather than editing it in-place, and for details about how to set up a service to watch this folder and clear the desktop file cache whenever it’s edited.
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ Macbook -> Kubuntu Slimbook update 2:
+
+After a brief dalliance with PopOS (which I liked well enough, but convinced me that I much prefer Plasma over Gnome), thanks to advice from someone on r/Kubuntu I discovered that most of my Kubuntu issues had been due to Slimbook delivering laptops with an old version of Kubuntu and the linux kernel on, which isn’t really compatible with their laptops (and I had foolishly assumed that the system software update would also update the kernel — not so) tl;dr: if you buy a Slimbook laptop and want to run Kubuntu on it, install it yourself!
+
+Desktop Environment
+
+After trying out Plasma on both X11 and Wayland, I decided to opt for sticking with Wayland, despite a few “showstoppers” and other minor annoyances. It has excellent support for a lot of quite slick features, such as fractional per-monitor UI scaling and multitouch gestures for switching virtual desktops (currently not yet configurable, hopefully this will change in the future).
+
+The current stable release of GIMP uses an old version of GTK which doesn’t scale well under Wayland, but fortunately the development release (2.99.16) has GTK3 support and the UI scales just fine.
+
+VLC also looks very weird under Plasma. I kept it around as it’s so useful, but also installed Celluloid 0.25.1 from their PPA as a potential Plasma-friendly replacement.
+
+Keyboards
+
+I type almost exclusively in ABC-Extended on my macbook, which gives me quick access to all the international characters I need access to, as well as some nice punctuation like en+em dashes, ellipses and curly quotes.
+
+I tried several keyboard layouts on my slimbook, and eventually settled for the English (Macintosh) one, which is almost the same with a few small differences. I will probably end up making my own keyboard layout which shifts some things around and replaces unused things with useful characters.
+
+For quick reference and learning different keyboard layouts, I recommend assigning this command to a global shortcut (I used ctrl+alt+shift+k), which brings up a keyboard preview, scaled to look good on my monitor. I haven’t found a good way of dismissing it other than using the trackpad (ideally I’d like it to only be displayed while I hold the shortcut), but it’s still very convenient.
+
+tastenbrett -qwindowgeometry 2500x850
+
+
+For some reason, my F2 button’s special feature is “toggle whether the super key is locked, without indicating the current status to the user at all”. Apparently this is a common feature, but some cursory research did not reveal why this would ever be useful, or what the intended use is. I also didn’t find many other people asking about it. What am I missing here? Why does anyone need an entire button dedicated to disabling another, unrelated button? Why can’t I make it do something useful?
+
+Mail
+
+For the moment I decided for Thunderbird for mail, contacts and calendars (more about those later), and it was easy enough to set up for mail. I’d much prefer something which looks and works like mac os Mail, but installing the Conversation extension went a long way to making it usable (despite not always finding all messages in a thread for some reason).
+
+Music
+
+For the moment I chose Quod Libet as a basic iTunes replacement. It successfully scanned the contents of Music/iTunes/iTunes Media/Music with no complaints, and even played the AAC m4a files after I installed kubuntu-restricted-extras. Unfortuantely Quod Libet (and every other media player I tried) seems to be unable to inhibit sleep under Wayland — hopefully this will be remedied soon, as the “create a NoSleep activity and switch to it whenever you want to play music” ““workaround”” is not particularly appealing. I’d also settle for a status bar widget which let me switch power profiles quickly.
+
+Photos
+
+Moving my photo library took a little more effort, but not much, thanks to osxphotos. Additionally installing exiftools and then running one command created a structured export of my entire library, with all the metadata I care about stored safely in EXIF fields:
+
+osxphotos export /Volumes/migration/photos --directory "{created.year}/{created.mm}" --filename "{created}T{created.hour}{created.min}{created.sec}{title?_,}{title,}" --skip-original-if-edited --jpeg-ext jpeg --exiftool
+
+
+This command takes the edited version of each file (falling back to the original), and stores them in a /YYYY/MM/YYYY-MM-DDTHHMMSS[_title].jpeg folder structure, which is my preferred way of organising photos on disk.
+
+I then imported this library into DigiKam, which quickly read all the metadata and made everything searchable. To get newly imported photos to fit into the same structure, I had to go into the Import Settings (plug in a camera or card, go “Import from device” and then open the sidebar on the right — unfortunately these settings don’t seem to be exposed anywhere else) and set the default filename to be the datetime, and the default “Album” to be YYYY/mm.
+
+I’m not a huge fan of DigiKam, as it’s cluttered, unstable and requires some very akward workflows (editing images opens them in a separate window? adding a tag requires opening the “tag manager”?? “hierarchical tags”??? I think the developers did not understand what a tag is and what makes them useful) but will do for now. To ensure longevity (and ease migrating to a different management application if I find something better suited to my workflow) I opted to store all metadata in EXIF fields in the files themselves. This way, DigiKam’s external database works as an ephemeral index and cache, which I can throw away or rebuild at any time without losing anything.
+
+A useful tip I learned along the way (thanks to ChatGPT): exiftool -a -u -g1 <file_name> will list all EXIF data found in a given file.
+
+Calendars and Contacts
+
+I set up a Nextcloud instance on my web host to see how much of my (already limited) iCloud usage it could replace. Despite learning that Hostinger doesn’t allow access to the .well-known directory required for zero-config carddav and caldav setup, I successfully managed to get my calendar and contacts migrated there. Thunderbird was able to sync with both without any issues, and mac os Calendar did eventually read my calendars from Nextcloud. No such luck with mac os Contacts unfortunately, but that’s much lower priority than calendar anyway.
+
+Pages and Numbers documents
+
+I had hoped that there would be a way of easily and mostly-losslessly batch converting all my Pages and Numbers documents into their microsoft XML equivalents, before then converting them to Libreoffice documents later on. Alas, that is only partially true. I ended up modifying a script provided by Viking OSX, which finds all Pages documents in a given folder and exports them as word docs to a separate folder. My changes instead export them in-place, and additionally export a PDF version so that I have a lossless read-only copy of each document exactly as it was:
+
+#!/bin/zsh
+
+: <<"COMMENT"
+Do a recursive descent on a folder hierarchy gathering Pages document. Export these
+documents from Pages as Word .docx and .pdf documents in the same location.
+Tested: Ventura 13.0.1
+VikingOSX, 2022-12-06, Apple Support Communities, No implicit warranty or support.
+Adapted by Barnaby Walters 2023-09-08
+COMMENT
+
+typeset -gi pagesCnt=0 docxCnt=0
+
+STARTDIR=$1
+
+function pages_export () {
+
+ /usr/bin/osascript <<-AS
+ use scripting additions
+
+ tell application "Pages"
+ activate
+ try
+ set infile to POSIX file "${1}"
+ set outfile to POSIX file "${2}"
+ set outfile_pdf to POSIX file "${3}"
+
+ set thisDoc to open infile as alias
+
+ with timeout of 1200 seconds
+ export thisDoc to file outfile as Microsoft Word
+ end timeout
+ with timeout of 1200 seconds
+ export thisDoc to file outfile_pdf as PDF
+ end timeout
+ close thisDoc saving no
+ on error errmsg number errNo
+ display dialog "[ " & errNo & " ]: " & errmsg
+ end try
+ end tell
+ -- unhide the exported filename extensions
+ tell application "Finder"
+ if exists (item outfile as alias) then
+ set extension hidden of (item outfile as alias) to false
+ end if
+ end tell
+ return
+AS
+}
+
+function completion () {
+ /usr/bin/osascript <<-AS
+ use scripting additions
+
+ set DialogIcon to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MultipleItemsIcon.icns"
+
+ display dialog "Pages documents found: " & "${1}" & return & ¬
+ "Pages documents exported to Word and PDF docx: " & "${2}" with title "Processing Complete" with icon POSIX file DialogIcon
+ return
+AS
+}
+
+# do a case-insensitive recursion finding Pages documents and sorting by name
+setopt nocaseglob
+for f in ${STARTDIR}/**/*.pages(.Non);
+do
+ (( ++pagesCnt ))
+ # if there is no Word folder at this file location, then make one
+
+ # construct the full path to the word docx document to be exported
+ wordfile="${f:a:h:r}/${f:r:t}.docx"
+ pdffile="${f:a:h:r}/${f:r:t}.pdf"
+
+ pages_export "${f}" "${wordfile}" "${pdffile}"
+
+ # do we have an exported docx that is non-zero in size?
+ [[ -s $wordfile ]] && (( ++docxCnt ))
+done
+
+# give the user statistics
+completion $pagesCnt $docxCnt
+
+
+(aside: I initially tried to get ChatGPT to generate the necessary applescript to do this entire task for me, as I’d heard that it was good at that, and applescript is a notoriously unintuitive and badly documented language. It seemd to get fairly close but I was unable to debug the (incomprehensible) errors in its scripts. The approach taken by VikingOSX is much more efficient: use applescript only for the things it’s absolutely necessary for, and do the rest in bash or python)
+
+I did the same thing for Numbers documents, the necessary script changes for that are left as an exercise for the reader.
+
+Unfortunately, these exports (and/or their subsequent imports into Libreoffice) were not very successful except for the simplest of documents. I only actively use a total of maybe 5 documents, which I will simply reconstruct from scratch in Libreoffice, and for the rest a combination of lossless read-only PDF and potentially-broken Office XML files should be sufficient.
+
+Prusa Slicer, AppImages and KDE Plasma LC_ALL issues
+
+The official way of installing Prusa Slicer on linux is using an AppImage, a format which I’ve had mixed experiences with. This was no different, as opening it in Dolphin had no result. Opening it in a console revealed some sort of locale error, and suggested some commands to fix it, but they also had no effect.
+
+After doing some digging, it turns out that it’s KDE Plasma’s fault. Plasma splits your localization settings up into various categories (language, time format, currency etc.) — an excellent feature by itself. Unfortunately, if you pick different locales for any of these categories, it leave the LC_ALL environment variable empty.
+
+The Prusa Slicer AppImage (and who knows what other software) was expecting an LC_ALL environment variable, and refused to run without it. tl;dr, editing /etc/defaults/locale to set LC_ALL and LANG to en_GB.utf-8 allowed PS to run, without having caused any other issues (yet…?).
+
+Once it managed to run, Prusa Slicer somehow told the system about itself in a way which lets me launch it from the application launcher (not something every AppImage does), and worked absolutely fine. Importing my settings as a config bundle worked perfectly.
+
+Documents and file syncing
+
+For the moment I decided against trying to set up two-way sync of my ~50GB documents folder between os x and Kubuntu. Nextcloud on my cheap web host is out of the question, and Syncthing look promising but I’d want to test its limitations and performance on something smaller first. For the moment, I decided to just use rsync for a one-way migration, and can repeat it in the future as I convert more proprietary files to linux-compatible formats.
+
+rsync -avzu --exclude venv --exclude .DS_Store --exclude .h5 Documents/ slimbook:Documents
+
+
+venv and .h5 files are excluded to avoid transferring another ~30GB of unnecessary data. For syncronization after the first one, I need to make sure that rsync isn’t going to delete or replace newer files, but I will figure that out when I get to it. -u makes sure that files which are newer (i.e. made or changed) on the kubuntu side are not overwritten on subsequent syncs
+
+Pain points and next steps
+
+
+- DigiKam seems powerful but its UI kinda sucks
+- Plasma is great but has some drawbacks which will hopefully be fixed Soon™
+- Notes — I’m a heavy mac os Notes user, and have fairly high standards for its replacement. Nextcloud notes looks promising, but the iOS app has two editor modes: one which is fast but sucks, and another which is good but takes ~7s to load each note.
+- Converting proprietary file formats to their linux equivalents. I have some old Sketch documents and a LOT of Eazydraw documents, all of which need converting losslessly and perfectly to well-structured SVGs for use with inkscape, before I can switch completely to Kubuntu for work tasks. I had hoped to use a similar Applescript trick, but haven’t been able to figure it out yet as Eazydraw lacks an applescript interface. Using System Events to manually manipulate the menus could work, but seems fiddly
+- …
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Notes from the first day using a Slimbook Executive running Kubuntu (probably applies to anyone moving from macos to Kubuntu on similar hardware)
+
+
+
+Generally, very good first impressions. The hardware is nice, the connectivity is perfect for me, it boots fast, the screen looks amazing. The keyboard and trackpad are fine, except for the surfboard trackpad button design. Came with a bunch of stupid marketing stickers on (what year is this, 2005?), most of which were easily removed.
+
+Here are the first settings I tweaked to make things more familiar:
+
+UI Scaling
+
+Settings -> Display and Monitor -> Global Scale = 200% for a readable UI while still remaining beautifully crisp.
+
+Settings -> Appearance -> Cursors -> Size: 48
+
+Settings -> Startup and Shutdown -> Login Screen -> Apply Plasma Settings so that your login screen is a sensible size.
+
+Right click status bar, enter edit mode, Panel height: 100
+
+Sleep
+
+Default sleep mode seems to be a hibernation which takes 10-20s to wake up from, including whenever you close the lid.
+
+Fix this by: In settings -> Power Management, in AC Powered tab set lid close to just turn off screen (or lock if desired). This will just turn off the screen when closed on AC power, but actually put the laptop to sleep when the lid is closed on battery power, to reduce power consumption.
+
+Then, sudo nano /etc/systemd/sleep.conf and uncomment AllowSuspendThenHibernate=yes, and reboot. This changes the behaviour of sleep to initially just suspend the system, keeping data in RAM and allowing immediate wake-ups. When the battery goes under 5%, it’ll instead hibernate, which takes 10-20s to wake up from but stores the contents of RAM on the SSD.
+
+EDIT: On further testing, this sadly doesn’t fix the issue completely (or at all? It’s hard to tell). Putting the computer to sleep using the meta menu works absolutely fine, but using F1 or the laptop lid (which I assume are handled the same way internally) leads to this blank screen with a cursor and hidden password entry field for 20s on wake up issue. I have no idea what’s causing it, and IMO it’s a big reason not to use KDE Plasma on these laptops — sadly, as it’s easily my favourite of the linux desktop environments I’ve tried so far.
+
+FURTHER EDIT: turns out this was all due to the laptop coming with an outdated linux kernel installed, which didn’t support the hardware. A fresh install of the latest Kubuntu works perfectly.
+
+Firefox
+
+By default, Firefox treats scroll events from the trackpad as scroll wheel inputs, causing jerky scrolling. To fix: echo MOZ_USE_XINPUT2=1 | sudo tee -a /etc/environment
+
+Touchpad
+
+Settings -> Input Devices -> Touchpad
+Pointer acceleration: 0.6
+Tap-to-click, tap-and-drag enabled
+Two-finger tap: right click
+Scrolling: two fingers, invert scroll direction
+Right click: press anywhere with two fingers
+
+Function Buttons
+
+Boot holding F2 to open BIOS settings, dig around to find and enable “Fn lock” to make the function keys perform their alternative functions by default (with numbered function inputs available by holding Fn, as on a MacBook)
+
+
+
+Next pain points which I didn’t find a solution to yet:
+
+
+- Occasional trackpad issues where the cursor freezes and only starts moving again after a two finger tap (right click). At the beginning this happened all the time, now it seems much better. Need to keep an eye on it.
+- File browser not having a column view. Apparently this is an ongoing struggle for years in Kubuntu, which seems hard to believe. I tried to install the ElementaryOS file viewer but it didn’t seem to work.
+- Setting up the keyboard for international typing. I got extremely used to typing special characters, diacritics and fancy punctuation on my macbook keyboard and am reluctant to have to re-learn all of that. Ideally I’d like to get a least a large subset of the key combinations working again.
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ CityNatureChallenge 2023 Wien Notable Observations
+
+
+ Vienna’s 2023 City Nature Challenge had more observers, observations and species than last year, and many observations still need final IDs. Here’s some of the more notable ones.
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ I’m a couple of weeks into 3D printing with a Creality Ender 3 S1 Pro. My initial impressions are: tl;dr: mechanically good, firmware bad. Either install synman’s pro firmware (requires a screen downgrade) or klipper (drops the screen and requires a raspberry pi — I went with MainsailOS) and you’ll have a very good printer for the price.
+
+Here’s my best 3D Benchy so far, printed in 55 minutes in PETG using Klipper
+
+
+Pros:
+
+
+- Mechanically solid and well built, comes very well packed, does not feel like the stereotypical “cheap chinese” product at all
+- Quick and easy to assemble (I recommend using loctite on all screws to prevent them coming loose from vibrations)
+- Some replacement parts available
+- Well supported with (mostly quite good) profiles available for various pieces of software
+- Touchscreen interface is fast and convenient to use if you’re satisfied with the stock firmware
+- Main board is not locked-down so it’s easy to install different firmware, and just as easy to revert to stock in the unlikely event that you want to
+
+
+Cons:
+
+
+- The stock firmware is very limited and has various problems.
+
+
+- Most notably, the “print on resume” feature causes uncontrollable pauses between layers, during which the nozzle will leak filament, causing huge blobs and stringing. Not possible to turn off in the UI, requires a
M413 S0 command added to the start g-code in your slicer (or changing to a different firmware, which you should do anyway). Here’s a comparison of the exact same part with and without “resume on power loss” enabled, both printed back when I was using the stock firmware: 
+- The auto bed leveling feels extremely unreliable and hard to trust
+- You can only see the first few characters of gcode files, so it’s impossible to differentiate between two similar files with different suffixes
+
+- Fiddly to perform firmware updates — screen and main board require separate files, sometimes in different folders depending on the chipset you have (which you can only check by opening the printer and looking at the hard-to-read MCU part number), always with a new filename otherwise it’ll fail silently, both will accept firmwares for different models with weird failure modes like a rotated screen
+- v-wheels riding in aluminium extrusions have a limited accuracy. Definitely good enough for a lot of purposes, but can warp and wear over time, will never be as good as precision-ground linear rods or (even better,) rails
+- XZ gantry arrived with loose Z nuts, causing huge amounts of Z kickback and preventing any kind of accurate movement. No indication that you have to tighten these in the instructions, and sources on the web inconsistent about what you should do about it. I ended up tightening mine up so they don’t rattle and have had no further issues.
+- Flex cable XZ clip position sticker was placed slightly wrong and awkward to adjust once in, and the flex cable end at the extruder requires better stress relief IMO. I added ~6cm of heatshrink tubing around it which works great
+- The provided slicer is horrible, I only tried it out to see if it’d fix my z blobbing problems. Fortunately Prusa Slicer works great with these printers
+
+
+I tuned mine up with the usual tools until I was satisfied with the prints using the stock firmware. Then I installed klipper and set up pressure advance and input shaping, vastly improving performance and usability.
+
+20mm calibration cubes printed 1) on the stock firmware, 2) Klipper with a speed profile, and 3) Klipper with a detail profile (i.e. slower outer perimeters):
+
+
+
+Here’s my current Prusa Slicer config files for the printer itself (Klipper) and my 0.16mm layer height optimal speed print profile.
+
+Here’s what my Klipper START_PRINT and END_PRINT macros ended up looking like:
+
+
+[gcode_macro START_PRINT]
+gcode:
+ {% set TOTAL_LAYER_COUNT = params.TOTAL_LAYER_COUNT|int %}
+ {% set BED_TEMP = params.BED_TEMP|float %}
+ {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|float %}
+
+SET_PRINT_STATS_INFO TOTAL_LAYER={TOTAL_LAYER_COUNT}
+ G90 ; use absolute coordinates
+ M83 ; extruder relative mode
+ M140 S{BED_TEMP} ; set final bed temp
+ M104 S{EXTRUDER_TEMP - 90} ; set temporary nozzle temp to prevent oozing during homing and auto bed leveling
+ G4 S10 ; allow partial nozzle warmup
+ G28 ; home all axis
+ M190 S{BED_TEMP} ; wait for bed temp to stabilize so that the bed mesh is accurate
+ BED_MESH_CALIBRATE
+ M104 S{EXTRUDER_TEMP} ; set final nozzle temp
+ G1 Z50 F240
+ G1 X2 Y10 F3000
+ M109 S{EXTRUDER_TEMP} ; wait for nozzle temp to stabilize
+ G1 Z0.28 F240
+ G92 E0
+ G1 Y140 E10 F1500 ; prime the nozzle
+ G1 X2.3 F5000
+ G92 E0
+ G1 Y10 E10 F1200 ; prime the nozzle
+ G92 E0
+
+[gcode_macro END_PRINT]
+gcode:
+ M140 S0 ; turn off heatbed
+ M104 S0 ; turn off temperature
+ M107 ; turn off fan
+ # Move nozzle away from print while retracting
+ G91
+ G1 X-2 Y-2 E-3 F300
+ # Raise nozzle by 10mm
+ G1 Z10 F3000
+ # Move out of the way
+ G90
+ G0 X20 Y150
+ # Disable steppers
+ M84 X Y E
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ From now on I will be making all reaction rolls with this die
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Mf2/waterpigs.co.uk_photo.jpg b/tests/Mf2/waterpigs.co.uk_photo.jpg
new file mode 100644
index 0000000..e0f436f
Binary files /dev/null and b/tests/Mf2/waterpigs.co.uk_photo.jpg differ
Hello
Name
Hello World
@@ -297,15 +302,17 @@ public function testMicroformatsNestedUnderUPropertyClassnamesDeriveValueFromURL }'; $mf = Mf2\parse($input); - $this->assertJsonStringEqualsJsonString(json_encode($mf), $expected); + $this->assertJsonStringEqualsJsonString(json_encode($mf, \JSON_THROW_ON_ERROR), $expected); + $this->assertIsArray($mf['items'][0]['properties']); $this->assertEquals($mf['items'][0]['properties']['comment'][0]['value'], 'https://example.com/post1234'); $this->assertEquals($mf['items'][0]['properties']['comment'][0]['properties']['author'][0]['value'], 'https://jane.example.com/'); } - public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFirstPName() { + public function testMicroformatsNestedUnderPPropertyClassnamesDeriveValueFromFirstPName(): void { $input = '
';
// Added root items key
$expected = '{
@@ -119,13 +121,13 @@ public function testSimplePersonImage() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2-implied-properties
*/
- public function testHyperlinkedImageNameAndPhotoProperties() {
+ public function testHyperlinkedImageNameAndPhotoProperties(): void {
$input = '
@@ -148,13 +150,13 @@ public function testHyperlinkedImageNameAndPhotoProperties() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
/**
* From https://microformats.org/wiki/microformats-2
*/
- public function testMoreDetailedPerson() {
+ public function testMoreDetailedPerson(): void {
$input = '
@@ -201,6 +203,6 @@ public function testMoreDetailedPerson() {
$parser = new Parser($input, '', true);
$output = $parser->parse();
- $this->assertJsonStringEqualsJsonString(json_encode($output), $expected);
+ $this->assertJsonStringEqualsJsonString(json_encode($output, \JSON_THROW_ON_ERROR), $expected);
}
}
diff --git a/tests/Mf2/ParseDTTest.php b/tests/Mf2/ParseDTTest.php
index 29252de..f82bec9 100644
--- a/tests/Mf2/ParseDTTest.php
+++ b/tests/Mf2/ParseDTTest.php
@@ -1,5 +1,7 @@
Multiple date and time values
@@ -514,6 +549,7 @@ public function testDtVCPMultipleDatesAndTimezones() { $parser = new Parser($input); $output = $parser->parse(); + $this->assertIsArray($output['items'][0]['properties']); $this->assertEquals('2014-06-01 12:30-0600', $output['items'][0]['properties']['start'][0]); $this->assertEquals('2014-06-01 19:30-0600', $output['items'][0]['properties']['end'][0]); } @@ -521,11 +557,12 @@ public function testDtVCPMultipleDatesAndTimezones() { /** * @see https://github.com/indieweb/php-mf2/issues/149 */ - public function testDtWithoutYear() { + public function testDtWithoutYear(): void { $input = 'Ordinal date
When: @@ -546,6 +583,7 @@ public function testNormalizeOrdinalDate() { $parser = new Parser($input); $output = $parser->parse(); + $this->assertIsArray($output['items'][0]['properties']); $this->assertEquals('2016-03-02 12:30-0600', $output['items'][0]['properties']['start'][0]); } } diff --git a/tests/Mf2/ParseHtmlIdTest.php b/tests/Mf2/ParseHtmlIdTest.php index d00390c..614fcbc 100644 --- a/tests/Mf2/ParseHtmlIdTest.php +++ b/tests/Mf2/ParseHtmlIdTest.php @@ -1,4 +1,7 @@
Recent Articles
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]);
}
- public function testParsesImpliedUPhotoFromImgSrcWithEmptyAlt() {
+ public function testParsesImpliedUPhotoFromImgSrcWithEmptyAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]['value']);
$this->assertEquals('', $output['items'][0]['properties']['photo'][0]['alt']);
}
- public function testParsesImpliedUPhotoFromImgSrcWithAlt() {
+ public function testParsesImpliedUPhotoFromImgSrcWithAlt(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('photo', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/img.png', $output['items'][0]['properties']['photo'][0]['value']);
$this->assertEquals('Example', $output['items'][0]['properties']['photo'][0]['alt']);
}
- public function testParsesImpliedUPhotoFromNestedImgSrc() {
+ public function testParsesImpliedUPhotoFromNestedImgSrc(): void {
$input = '

Tantek Çelik';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertArrayHasKey('photo', $result['items'][0]['properties']);
$this->assertEquals('https://pbs.twimg.com/profile_images/423350922408767488/nlA_m2WH.jpeg', $result['items'][0]['properties']['photo'][0]);
}
- public function testIgnoredPhotoIfMultipleImg() {
+ public function testIgnoredPhotoIfMultipleImg(): void {
$input = '
Moar text
blah blah blah
blah blah blah
My Name
Test Feed
En svensk titel
Example User
The day I saw a 
Street Name 9
12345 NY, USA





';
$parser = new Parser($input, 'https://example.com/things/more.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/image.png', $output['items'][0]['properties']['photo'][0]);
}
/**
* @group baseUrl
*/
- public function testResolvesRelativeBaseRelativeUrlsInImpliedMicroformats() {
+ public function testResolvesRelativeBaseRelativeUrlsInImpliedMicroformats(): void {
$input = '
';
$parser = new Parser($input, 'https://example.com/');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals('https://example.com/things/image.png', $output['items'][0]['properties']['photo'][0]);
}
/** @see https://github.com/indieweb/php-mf2/issues/33 */
- public function testParsesHrefBeforeValueClass() {
+ public function testParsesHrefBeforeValueClass(): void {
$input = 'WRONG';
$result = Mf2\parse($input);
+ $this->assertIsArray($result['items'][0]['properties']);
$this->assertEquals('https://example.com/right', $result['items'][0]['properties']['url'][0]);
}
/**
* @group parseU
*/
- public function testParseUHandlesAudio() {
+ public function testParseUHandlesAudio(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('audio', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/audio.mp3', $output['items'][0]['properties']['audio'][0]);
}
@@ -217,11 +237,12 @@ public function testParseUHandlesAudio() {
/**
* @group parseU
*/
- public function testParseUHandlesVideo() {
+ public function testParseUHandlesVideo(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
}
@@ -229,11 +250,12 @@ public function testParseUHandlesVideo() {
/**
* @group parseU
*/
- public function testParseUHandlesVideoNoSrc() {
+ public function testParseUHandlesVideoNoSrc(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('no video support', $output['items'][0]['properties']['video'][0]);
}
@@ -241,11 +263,12 @@ public function testParseUHandlesVideoNoSrc() {
/**
* @group parseU
*/
- public function testParseUHandlesSource() {
+ public function testParseUHandlesSource(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
$this->assertEquals('https://example.com/video.ogg', $output['items'][0]['properties']['video'][1]);
@@ -254,11 +277,12 @@ public function testParseUHandlesSource() {
/**
* @group parseU
*/
- public function testParseUHandlesVideoPoster() {
+ public function testParseUHandlesVideoPoster(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('video', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/video.mp4', $output['items'][0]['properties']['video'][0]);
$this->assertEquals('https://example.com/posterimage.jpg', $output['items'][0]['properties']['photo'][0]);
@@ -267,11 +291,12 @@ public function testParseUHandlesVideoPoster() {
/**
* @group parseU
*/
- public function testParseUWithSpaces() {
+ public function testParseUWithSpaces(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com', $output['items'][0]['properties']['url'][0]);
}
@@ -279,7 +304,7 @@ public function testParseUWithSpaces() {
/**
* @see https://github.com/indieweb/php-mf2/issues/130
*/
- public function testImpliedUWithEmptyHref() {
+ public function testImpliedUWithEmptyHref(): void {
$input = 'Jane Doe
@@ -288,23 +313,28 @@ public function testImpliedUWithEmptyHref() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][1]['properties']);
$this->assertArrayHasKey('url', $output['items'][1]['properties']);
$this->assertEquals('https://example.com/', $output['items'][1]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][2]['properties']);
$this->assertArrayHasKey('url', $output['items'][2]['properties']);
$this->assertEquals('https://example.com/', $output['items'][2]['properties']['url'][0]);
+ $this->assertIsArray($output['items'][3]['properties']);
$this->assertArrayHasKey('url', $output['items'][3]['properties']);
$this->assertEquals('https://example.com/', $output['items'][3]['properties']['url'][0]);
+ $this->assertArrayHasKey('children', $output['items'][4]);
$this->assertArrayHasKey('url', $output['items'][4]['children'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][4]['children'][0]['properties']['url'][0]);
}
- public function testValueFromLinkTag() {
+ public function testValueFromLinkTag(): void {
$input = <<< END
@@ -318,6 +348,8 @@ public function testValueFromLinkTag() {
$parser = new Parser($input, 'https://example.com');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
+
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/', $output['items'][0]['properties']['url'][0]);
@@ -325,10 +357,11 @@ public function testValueFromLinkTag() {
$this->assertEquals('Example.com homepage', $output['items'][0]['properties']['name'][0]);
}
- public function testResolveFromDataElement() {
+ public function testResolveFromDataElement(): void {
$parser = new Parser('', 'https://example.com/index.html');
$output = $parser->parse();
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertArrayHasKey('url', $output['items'][0]['properties']);
$this->assertEquals('https://example.com/relative.html', $output['items'][0]['properties']['url'][0]);
}
@@ -336,7 +369,7 @@ public function testResolveFromDataElement() {
/**
* @see https://github.com/microformats/php-mf2/issues/182
*/
- public function testResolveFromIframeElement() {
+ public function testResolveFromIframeElement(): void {
$input = 'Title
Name (this should not be included) Endname
Wrong Name (this should not be included)
Wrong Name (this should not be included)
test
@@ -88,21 +95,25 @@ public function testParsesValueTitleDatetimes() { $parser = new Parser($input); $output = $parser->parse(); + $this->assertIsArray($output['items'][0]['properties']); $this->assertEquals('2012-02-16T16:14:47+00:00', $output['items'][0]['properties']['published'][0]); } /** @see https://github.com/indieweb/php-mf2/issues/34 */ - public function testIgnoresValueClassNestedFurtherThanChild() { + public function testIgnoresValueClassNestedFurtherThanChild(): void { $test = 'Blah blah thing.
The br tag should not be converted to an XML br/br element.
The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['html']); $this->assertEquals('Here is content with two lines.'."\n".'The br tag should not be converted to an XML br/br element.', $output['items'][0]['properties']['content'][0]['value']); } - public function testParseEWithWhitespace() { + public function testParseEWithWhitespace(): void { $input = '
', $output['items'][0]['properties']['name'][0]); $this->assertEquals('
Test
1
2
1
2
', $output['items'][0]['properties']['content'][0]['html']); } /** * @see https://github.com/indieweb/php-mf2/issues/158 */ - public function testPrefixWithNumbers() { + public function testPrefixWithNumbers(): void { $input = 'Too many dashes @@ -776,6 +853,7 @@ public function testConsecutiveDashes() { $this->assertCount(1, $output['items'][0]['type']); $this->assertEquals('h-entry', $output['items'][0]['type'][0]); + $this->assertIsArray($output['items'][0]['properties']); $this->assertCount(1, $output['items'][0]['properties']); $this->assertArrayHasKey('name', $output['items'][0]['properties']); } @@ -787,7 +865,7 @@ public function testConsecutiveDashes() { * @see https://github.com/indieweb/php-mf2/issues/160 * @see https://github.com/indieweb/php-mf2/issues/158 */ - public function testMfClassRegex() { + public function testMfClassRegex(): void { $input = '
Name
@@ -896,10 +978,11 @@ public function testPropertyWithInvalidHPrefixedRootClassParsed() {
EOF;
$output = Mf2\parse($input);
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(array('value' => '/image.jpg', 'alt' => 'Jon Doe'), $output['items'][0]['properties']['photo'][0]);
}
- public function testGetRootMfOnlyFindsValidElements() {
+ public function testGetRootMfOnlyFindsValidElements(): void {
$input = <<
@@ -959,7 +1043,7 @@ public function testInvalidRootsIgnored() {
/**
* @see https://github.com/microformats/php-mf2/issues/249
*/
- public function testInvalidNestedRootsIgnored() {
+ public function testInvalidNestedRootsIgnored(): void {
$input = <<
@@ -986,7 +1070,7 @@ public function testInvalidNestedRootsIgnored() {
/**
* @see https://github.com/microformats/php-mf2/issues/249
*/
- public function testInvalidNestedPropertiesIgnored1() {
+ public function testInvalidNestedPropertiesIgnored1(): void {
$input = <<
@@ -1000,6 +1084,7 @@ public function testInvalidNestedPropertiesIgnored1() {
$output = Mf2\parse($input);
# `properties` should be empty
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(0, count($output['items'][0]['properties']));
# `children` should have length=2
@@ -1014,7 +1099,7 @@ public function testInvalidNestedPropertiesIgnored1() {
/**
* @see https://github.com/microformats/php-mf2/issues/246
*/
- public function testInvalidNestedPropertiesIgnored2() {
+ public function testInvalidNestedPropertiesIgnored2(): void {
$input = <<
TITLE
@@ -1028,6 +1113,7 @@ public function testInvalidNestedPropertiesIgnored2() {
$output = Mf2\parse($input);
# `properties` should have length=3
+ $this->assertIsArray($output['items'][0]['properties']);
$this->assertEquals(3, count($output['items'][0]['properties']));
# should have these properties
diff --git a/tests/Mf2/PlainTextTest.php b/tests/Mf2/PlainTextTest.php
index 0bcdd3e..c78bb80 100644
--- a/tests/Mf2/PlainTextTest.php
+++ b/tests/Mf2/PlainTextTest.php
@@ -1,5 +1,7 @@
parse();
$entryProperties = $output['items'][0]['properties'];
+ $this->assertIsArray($entryProperties);
$this->assertEquals($pName, $entryProperties['name'][0]);
$this->assertEquals($eValue, $entryProperties['content'][0]['value']);
$this->assertEquals($eHtml, $entryProperties['content'][0]['html']);
}
- public function aaronpkExpectations() {
+ /**
+ * @return array
+ */
+ public function aaronpkExpectations(): array {
return array(
1 => array(
"\n Hello World
\n",
diff --git a/tests/Mf2/RelTest.php b/tests/Mf2/RelTest.php
index a4f1d32..86385a5 100644
--- a/tests/Mf2/RelTest.php
+++ b/tests/Mf2/RelTest.php
@@ -1,4 +1,7 @@
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOnATag() {
+ public function testRelValueOnATag(): void {
$input = 'webmention me';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOnAreaTag() {
+ public function testRelValueOnAreaTag(): void {
$input = '';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/webmention', $output['rels']['webmention'][0]);
}
- public function testRelValueOrder() {
+ public function testRelValueOrder(): void {
$input = '
webmention me
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][2]);
}
- public function testRelValueOrder2() {
+ public function testRelValueOrder2(): void {
$input = '
webmention me';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][2]);
}
- public function testRelValueOrder3() {
+ public function testRelValueOrder3(): void {
$input = '
@@ -76,21 +84,23 @@ public function testRelValueOrder3() {
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayHasKey('webmention', $output['rels']);
$this->assertEquals('https://example.com/link', $output['rels']['webmention'][0]);
$this->assertEquals('https://example.com/a', $output['rels']['webmention'][1]);
$this->assertEquals('https://example.com/area', $output['rels']['webmention'][2]);
}
- public function testRelValueOnBTag() {
+ public function testRelValueOnBTag(): void {
$input = 'this makes no sense';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertArrayNotHasKey('webmention', $output['rels']);
}
- public function testEnableAlternatesFlagTrue() {
+ public function testEnableAlternatesFlagTrue(): void {
$input = 'author a
author b
post 1
@@ -106,7 +116,7 @@ public function testEnableAlternatesFlagTrue() {
$this->assertArrayHasKey('alternates', $output);
}
- public function testEnableAlternatesFlagFalse() {
+ public function testEnableAlternatesFlagFalse(): void {
$input = 'author a
author b
post 1
@@ -126,7 +136,7 @@ public function testEnableAlternatesFlagFalse() {
* @see https://github.com/indieweb/php-mf2/issues/112
* @see https://microformats.org/wiki/microformats2-parsing#rel_parse_examples
*/
- public function testRelURLs() {
+ public function testRelURLs(): void {
$input = 'author a
author b
post 1
@@ -139,14 +149,14 @@ public function testRelURLs() {
$parser = new Parser($input);
$output = $parser->parse();
- $this->assertArrayHasKey('rels', $output);
+ $this->assertIsArray($output['rels']);
$this->assertCount(4, $output['rels']);
$this->assertArrayHasKey('author', $output['rels']);
$this->assertArrayHasKey('in-reply-to', $output['rels']);
$this->assertArrayHasKey('alternate', $output['rels']);
$this->assertArrayHasKey('home', $output['rels']);
- $this->assertArrayHasKey('rel-urls', $output);
+ $this->assertIsArray($output['rel-urls']);
$this->assertCount(6, $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/a', $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/b', $output['rel-urls']);
@@ -155,18 +165,24 @@ public function testRelURLs() {
$this->assertArrayHasKey('https://example.com/fr', $output['rel-urls']);
$this->assertArrayHasKey('https://example.com/articles.atom', $output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/a']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/a']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/a']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/b']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/b']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/b']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/1']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/1']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/1']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/2']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/2']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/2']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('text', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('media', $output['rel-urls']['https://example.com/fr']);
$this->assertArrayHasKey('hreflang', $output['rel-urls']['https://example.com/fr']);
+ $this->assertIsArray($output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('title', $output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('type', $output['rel-urls']['https://example.com/articles.atom']);
$this->assertArrayHasKey('rels', $output['rel-urls']['https://example.com/articles.atom']);
@@ -176,42 +192,52 @@ public function testRelURLs() {
* @see https://github.com/microformats/microformats2-parsing/issues/29
* @see https://github.com/microformats/microformats2-parsing/issues/30
*/
- public function testRelURLsRelsUniqueAndSorted() {
+ public function testRelURLsRelsUniqueAndSorted(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['rels'], array('archived', 'bookmark', 'me'));
}
- public function testRelURLsInfoMergesCorrectly() {
+ public function testRelURLsInfoMergesCorrectly(): void {
$input = 'This nodeValue
Not this nodeValue';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#']);
+ $this->assertArrayHasKey('hreflang', $output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['hreflang'], 'en');
$this->assertArrayNotHasKey('media', $output['rel-urls']['#']);
$this->assertArrayNotHasKey('title', $output['rel-urls']['#']);
$this->assertArrayNotHasKey('type', $output['rel-urls']['#']);
+ $this->assertArrayHasKey('text', $output['rel-urls']['#']);
$this->assertEquals($output['rel-urls']['#']['text'], 'This nodeValue');
}
- public function testRelURLsNoDuplicates() {
+ public function testRelURLsNoDuplicates(): void {
$input = '
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rels']);
$this->assertEquals($output['rels']['a'], array('#a', '#b'));
}
- public function testRelURLsFalsyTextVSEmpty() {
+ public function testRelURLsFalsyTextVSEmpty(): void {
$input = '0
';
$parser = new Parser($input);
$output = $parser->parse();
+ $this->assertIsArray($output['rel-urls']);
+ $this->assertIsArray($output['rel-urls']['#a']);
$this->assertArrayHasKey('text', $output['rel-urls']['#a']);
$this->assertEquals($output['rel-urls']['#a']['text'], '0');
+ $this->assertIsArray($output['rel-urls']['#b']);
$this->assertArrayNotHasKey('text', $output['rel-urls']['#b']);
}
diff --git a/tests/Mf2/URLTest.php b/tests/Mf2/URLTest.php
index 2da4691..96efe82 100644
--- a/tests/Mf2/URLTest.php
+++ b/tests/Mf2/URLTest.php
@@ -1,5 +1,7 @@
assertEquals('one/two', $input);
@@ -25,7 +27,7 @@ public function testRemoveLeadingDotSlash() {
$this->assertEquals('one/two', $input);
}
- public function testRemoveLeadingSlashDot() {
+ public function testRemoveLeadingSlashDot(): void {
$input = '/./one/two';
mf2\removeLeadingSlashDot($input);
$this->assertEquals('/one/two', $input);
@@ -43,7 +45,7 @@ public function testRemoveLeadingSlashDot() {
$this->assertEquals('/../../g', $input);
}
- public function testRemoveOneDirLevel() {
+ public function testRemoveOneDirLevel(): void {
$input = '/../../g';
$output = '/a/b/c';
mf2\removeOneDirLevel($input, $output);
@@ -57,7 +59,7 @@ public function testRemoveOneDirLevel() {
$this->assertEquals('/a/b', $output);
}
- public function testRemoveLoneDotDot() {
+ public function testRemoveLoneDotDot(): void {
$input = '.';
mf2\removeLoneDotDot($input);
$this->assertEquals('', $input);
@@ -67,7 +69,7 @@ public function testRemoveLoneDotDot() {
$this->assertEquals('', $input);
}
- public function testMoveOneSegmentFromInput() {
+ public function testMoveOneSegmentFromInput(): void {
$input = '/a/b/c/./../../g';
$output = '';
mf2\moveOneSegmentFromInput($input, $output);
@@ -96,12 +98,15 @@ public function testMoveOneSegmentFromInput() {
/**
* @dataProvider removeDotSegmentsData
*/
- public function testRemoveDotSegments($assert, $path, $expected) {
+ public function testRemoveDotSegments(string $assert, string $path, string $expected): void {
$actual = mf2\removeDotSegments($path);
$this->assertEquals($expected, $actual, $assert);
}
- public function removeDotSegmentsData() {
+ /**
+ * @return list
+ */
+ public function removeDotSegmentsData(): array {
return array(
array('Should remove .. and .',
'/a/b/c/./../../g', '/a/g'),
@@ -109,11 +114,13 @@ public function removeDotSegmentsData() {
'/a/b/c/d/../../../g', '/a/g'),
array('Should not add leading slash',
'a/b/c', 'a/b/c'),
+ array('Should remove extra ..',
+ '/a/b/../../../..', '/'),
);
}
- public function testNoPathOnBase() {
+ public function testNoPathOnBase(): void {
$actual = mf2\resolveUrl('https://example.com', '');
$this->assertEquals('https://example.com/', $actual);
@@ -124,7 +131,7 @@ public function testNoPathOnBase() {
$this->assertEquals('https://example.com/#thing', $actual);
}
- public function testMisc() {
+ public function testMisc(): void {
$expected = 'http://a/b/c/g';
$actual = mf2\resolveUrl('http://a/b/c/d;p?q', './g');
$this->assertEquals($expected, $actual);
@@ -139,7 +146,7 @@ public function testMisc() {
}
/** as per https://github.com/indieweb/php-mf2/issues/35 */
- public function testResolvesProtocolRelativeUrlsCorrectly() {
+ public function testResolvesProtocolRelativeUrlsCorrectly(): void {
$expected = 'https://cdn.example.com/thing/asset.css';
$actual = Mf2\resolveUrl('https://example.com', '//cdn.example.com/thing/asset.css');
$this->assertEquals($expected, $actual);
@@ -152,13 +159,16 @@ public function testResolvesProtocolRelativeUrlsCorrectly() {
/**
* @dataProvider dataProvider
*/
- public function testReturnsUrlIfAbsolute($assert, $base, $url, $expected) {
+ public function testReturnsUrlIfAbsolute(string $assert, string $base, string $url, string $expected): void {
$actual = mf2\resolveUrl($base, $url);
$this->assertEquals($expected, $actual, $assert);
}
- public function dataProvider() {
+ /**
+ * @return list
+ */
+ public function dataProvider(): array {
// seriously, please update to PHP 5.4 so I can use nice array syntax ;)
// fail message, base, url, expected
$cases = array(
@@ -253,14 +263,8 @@ public function dataProvider() {
);
- // PHP 5.4 and before returns a different result, but either are acceptable
- if(PHP_MAJOR_VERSION <= 5 && PHP_MINOR_VERSION <= 4) {
- $cases[] = array('relative add scheme host user from base',
- 'http://user:@www.example.com', 'server.php', 'http://user@www.example.com/server.php');
- } else {
- $cases[] = array('relative add scheme host user from base',
- 'http://user:@www.example.com', 'server.php', 'http://user:@www.example.com/server.php');
- }
+ $cases[] = array('relative add scheme host user from base',
+ 'http://user:@www.example.com', 'server.php', 'http://user:@www.example.com/server.php');
// Test cases from RFC
// http://tools.ietf.org/html/rfc3986#section-5.4
diff --git a/tests/Mf2/aaron.pk_4Zn5.html b/tests/Mf2/aaron.pk_4Zn5.html
new file mode 100644
index 0000000..38b8d7c
--- /dev/null
+++ b/tests/Mf2/aaron.pk_4Zn5.html
@@ -0,0 +1,426 @@
+
+
+
+
+
+ SFO ✈️ SLC ✈️ PDX #travel • Aaron Parecki
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WeChat ID
aaronpk_tv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Mf2/bootstrap.php b/tests/Mf2/bootstrap.php
index db629b3..8c60253 100644
--- a/tests/Mf2/bootstrap.php
+++ b/tests/Mf2/bootstrap.php
@@ -1,3 +1,5 @@
+
+
+
+
+
+
+
+
+
+
+
+ Barnaby Walters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ New corollary to the 2010s classic snarky programmer adage “the cloud is someone else’s computer”:
+
+“AI is someone else’s GPU”
+
+from which it follows that
+
+“I’m starting a new company with AI someone else’s GPU”
+
+“I spent hours talking to AI someone else’s GPU about my life and the AI someone else’s GPU told me to break up with my boyfriend”
+
+“I’m worried that my job is in danger of being replaced by AI someone else’s GPU“
+
+“It’s crazy what convincing images AI someone else’s GPU can generate these days!” (okay, that one doesn’t sound so far-fetched)
+
+“Users expect our product to have advanced features and integration with AI someone else’s GPU”
+
+“AI someone else’s GPU is the defining technology of the decade, if not the century”
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ Here’s a KDE Plasma service menu (dolphin context menu action) for creating a valid CACHEDIR.TAG file in the selected folder. Useful for excluding things from being backed up! (e.g. via restic with the --exclude-caches option)
+
+[Desktop Entry]
+Type=Service
+MimeType=inode/directory
+Actions=create_cachedir_tag
+
+[Desktop Action create_cachedir_tag]
+Name=Create CACHEDIR.TAG
+Icon=breeze/actions/22/document-edit-encrypt
+Exec=echo "Signature: 8a477f597d28d172789f06886806bc55" > %u/CACHEDIR.TAG
+
+
+Put it somewhere like .local/share/kio/servicemenus/cachedir-tag.desktop, make it executable and it should show up in your context menu.
+
+
+
+
+
+
+ -
+
+
+
+
+
+ At the time of writing, due to a packaging mess-up, the builds of SDR++ (and many other SDR tools by the looks of it) have suddenly and unintentionally dropped support for the popular RTL-SDR software defined radio dongle. Until this is fixed, users will have to build these applications themselves. The instructions are a little lacking in details, so here’s exactly how to do that, working on Kubuntu:
+
+
+# To install:
+sudo aptitude install cmake libfftw3-dev libglfw3-dev libvolk-dev zstd libairspy-dev librtlsdr-dev
+git clone https://github.com/AlexandreRouma/SDRPlusPlus.git
+cd SDRPlusPlus
+mkdir build
+cd build
+cmake ..
+make -j5 # 5 is the number of threads to use for building. adjust to your preference
+sh ../create_root.sh
+sudo make install
+
+# To run:
+sdrpp
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Reddit recently underwent another new, unpopular redesign, meaning that there are now three different UIs for accessing the website. Out of habit I would look at new-new reddit before remembering to switch to old-new reddit, and quickly noticed that looking at new-new reddit causes my laptop’s fans instantly start spinning.
+
+Here’s a firefox performance profile for 20-30s of each iteration of the reddit homepage. I simply loaded the page and did absolutely nothing.
+
+old.reddit.com: constant ~5% CPU usage with occasional spikes up to ~90%
+
+
+
+new.reddit.com: usually 0% CPU usage with occasional bursts up to ~50%
+
+
+
+reddit.com (new-new reddit): constant 30% CPU usage with occasional spikes even higher
+
+
+
+I don’t have the time or knowledge required to dig into the performance profiler but I would be fascinated to know how old-new reddit ended up more efficient than old-old reddit, and exactly what new-new reddit is doing with 30% of my CPU??
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ When importing photos into DigiKam, I want them to be renamed based on the ISO8601 datetime they were taken, ideally to millisecond precision to avoid conflicts when multiple images were taken in a single second. This has the nice side-effect that photos from multiple camera sources are guaranteed to be displayed in the correct order when browsing files, which is important and practical for me.
+
+I started out using this custom file renaming template on import:
+
+[date:"yyyy-MM-ddTHHMMss"]-[file]
+
+
+as DigiKam’s [date] placeholder didn’t have an option for milliseconds, and I couldn‘t find a counter option which could handle my desired “append -# per-collision if this renaming scheme results in collisions”, so ended up just adding the entire camera-generated filename to the end.
+
+Unfortunately, this led to my files all being in the wrong order, even from the same camera. I haven’t quite figured out why, but it seems that there are several different internal datetime values stored in the image files: file creation date (which is completely wrong), the values used in DigiKam’s [date] templates (which are mostly wrong), and the DateTimeOriginal values stored in Exif data, which are not only correct but provide sub-second resolution too!
+
+So here’s the DigiKam import naming template which I will be using going forward:
+
+[meta:Exif.Photo.DateTimeOriginal]{range:1,10}{replace:":","-"}T[meta:Exif.Photo.DateTimeOriginal]{range:12,}{replace:":",""}s[meta:Exif.Photo.SubSecTimeOriginal]
+
+
+which produces ISO8601-ish filenames like this:
+
+2023-06-16T143139s922.JPG
+
+
+Broken down,
+
+[meta:Exif.Photo.DateTimeOriginal]
+
+
+evalulates to a string like
+
+2023:06:16 14:31:39
+
+
+but I don’t want colons in filenames for portability, so I take only the date part with {range:1,10}, replace the colons with hyphens {replace:":","-"}, add a literal T separator to avoid spaces in filenames, take the time part of the datetime and remove the colons completely, add a literal s separator to delimit seconds and milliseconds as I wanted to keep them separate but not use the typical . delimiter.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Ended up getting frustrated with the old version of DigiKam available on Kubuntu, so tried installing an AppImage. The state of AppImage integration with Kubuntu is abysmal, and I open DigiKam fairly regularly, so I finally tried installing AppImageLauncher, which is recommended by DigiKam and is supposed to be a good tool for integrating AppImages with the desktop environment (something which Plasma should surely do itself, if AppImages are really going to be part of the future of linux app packaging).
+
+Unfortunately, installing AppImageLauncher completely broke my desktop environment, causing it to hang and preventing me from logging in. Looked it up and it was clearly related to whatever this issue is about, as moving .local/share/mime fixed it. Removing AppImageLauncher and the mime cache got things working again, and, lo, before it broke my system, AppImageLauncher had kindly made .desktop files for all my AppImages!
+
+At this point I decided to take a more manual approach to integrating AppImages I cared about with my DE, so I added a link from ~/Applications (where I store AppImages and other applications not installed via the package manager) to ~/.local/share/applications, where .desktop files are kept. Having quick access to this location makes manually managing .desktop files much more bearable, and I went about improving the ones AppImageLauncher had made (e.g. adding version numbers to the names – I find it very useful to know what version of an app I’m launching).
+
+So, back to DigiKam: at this point I had a DigiKam 8.3 AppImage installed and openable via launchers thanks to the .desktop file. It had to re-download the facial recognition files, but other than that picked up everything from before. However, in the main photo list view, the maximum size of the thumbnails was tiny.
+
+I spent some time poking around in settings and tweaking the QT scaling factor via the .desktop file, but I’ll spare you the details. tl;dr: if you want the DigiKam 8.3 AppImage to let you see large thumbnails on a high-DPI screen, you need to check the following boxes:
+
+
+- Miscellaneous → System → Use high DPI scaling from the screen factor
+- Vews → Icons → Use large thumbnail size for high screen resolution
+
+
+Restart DigiKam, and it should let you make thumbnails large enough to be useful. This is especially necessary seeing as how DigiKam’s photo list view has a horribly wasteful layout, with almost as much whitespace as photo surface area.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you run into weird “file corrupt or unwritable” errors when trying to tag/rename tracks with Picard on (k)ubuntu, check whether the files are read-only. When using Dolphin to rip and encode CDs (an excellent feature – Dolphin continues to surprise me) it retains their read-only permissions when copying them to your disk, rather than setting it to something sensible.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Drew ferris with a soldering iron as I couldn‘t find much embedded rust art
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Some tips for using Teensy on linux:
+
+The teensy board support package is only supported in the Arduino applications downloaded directly from the arduino site, NOT on versions distributed by package managers. I used the AppImage and it worked fine. If you try to install the teensy board package on an unsupported version of Arduino you might see errors like “archive not supported”.
+
+Even when you have a supported version of Arduino installed, installing the Teensy board package isn’t totally reliable. The first time I downloaded it, compiling would fail with the following error:
+
+fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory
+
+Compilation error: fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory
+
+
+The 11.3.1 folder existed, but was empty. Down- then upgrading the board package didn‘t fix it. Removing the board package and reinstalling it did work.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you’re getting the following error in Inkscape on (k)ubuntu when trying to open the Extension Manager:
+
+[long traceback snipped]
+ModuleNotFoundError: No module named 'appdirs'
+
+
+the best way to deal with it seems to be sudo apt install python3-appdirs, as trying to install the appdirs module with pip or pip3 might not put it in the right place for the system python3 which inkscape is using, especially if you use something like conda or pyenv.
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ In a world where even “digital-natives” increasingly don’t understand basic file management, and where it’s more and more common for user data to be siloed per-app even on desktops, I propose a corollary to Zawinski’s Law: “All apps which don’t store data transparently in the file system are doomed to implement their own limited and fragile filesystem equivalent”
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ If you’re in the unfortunate position of needing to use MuseScore4 on linux for some reason (for example to use its excellent MIDI to notation conversion) and are having issues with the Flatpak version having an unreadably tiny UI on high-DPI screens, here’s how to fix it.
+
+Open the .desktop file for MuseScore 4 – mine was in /var/lib/flatpak/app/org.musescore.MuseScore/current/active/export/share/applications/org.musescore.MuseScore.desktop
+
+Find the Exec key, and change the command to include --env=QT_SCALE_FACTOR=2. Mine ended up looking like this:
+
+Exec=/usr/bin/flatpak run --env=QT_SCALE_FACTOR=2 --branch=stable --arch=x86_64 --command=mscore --file-forwarding org.musescore.MuseScore @@ %F @@
+
+
+Save (you’ll need to enter your password, or to have launched the editor with sudo).
+
+Try launching MuseScore again. If you’re lucky, it’ll have a readable UI. If not, try restarting and launching it again — I haven’t found a way of successfully getting KDE to force-update all its .desktop files. Presumably there’s a cache somewhere? If anyone knows how to reliably do this, please let me know!
+
+
+This should work for any Flatpak which uses QT, on any desktop environment which uses .desktop files. I really hope “UI Scale” becomes a standard per-application setting in the near future.
+
+EDIT: thanks to carmanaught on the KDE forums for this additional suggestion to copy the .desktop file to ~/.local/share/applications rather than editing it in-place, and for details about how to set up a service to watch this folder and clear the desktop file cache whenever it’s edited.
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ Macbook -> Kubuntu Slimbook update 2:
+
+After a brief dalliance with PopOS (which I liked well enough, but convinced me that I much prefer Plasma over Gnome), thanks to advice from someone on r/Kubuntu I discovered that most of my Kubuntu issues had been due to Slimbook delivering laptops with an old version of Kubuntu and the linux kernel on, which isn’t really compatible with their laptops (and I had foolishly assumed that the system software update would also update the kernel — not so) tl;dr: if you buy a Slimbook laptop and want to run Kubuntu on it, install it yourself!
+
+Desktop Environment
+
+After trying out Plasma on both X11 and Wayland, I decided to opt for sticking with Wayland, despite a few “showstoppers” and other minor annoyances. It has excellent support for a lot of quite slick features, such as fractional per-monitor UI scaling and multitouch gestures for switching virtual desktops (currently not yet configurable, hopefully this will change in the future).
+
+The current stable release of GIMP uses an old version of GTK which doesn’t scale well under Wayland, but fortunately the development release (2.99.16) has GTK3 support and the UI scales just fine.
+
+VLC also looks very weird under Plasma. I kept it around as it’s so useful, but also installed Celluloid 0.25.1 from their PPA as a potential Plasma-friendly replacement.
+
+Keyboards
+
+I type almost exclusively in ABC-Extended on my macbook, which gives me quick access to all the international characters I need access to, as well as some nice punctuation like en+em dashes, ellipses and curly quotes.
+
+I tried several keyboard layouts on my slimbook, and eventually settled for the English (Macintosh) one, which is almost the same with a few small differences. I will probably end up making my own keyboard layout which shifts some things around and replaces unused things with useful characters.
+
+For quick reference and learning different keyboard layouts, I recommend assigning this command to a global shortcut (I used ctrl+alt+shift+k), which brings up a keyboard preview, scaled to look good on my monitor. I haven’t found a good way of dismissing it other than using the trackpad (ideally I’d like it to only be displayed while I hold the shortcut), but it’s still very convenient.
+
+tastenbrett -qwindowgeometry 2500x850
+
+
+For some reason, my F2 button’s special feature is “toggle whether the super key is locked, without indicating the current status to the user at all”. Apparently this is a common feature, but some cursory research did not reveal why this would ever be useful, or what the intended use is. I also didn’t find many other people asking about it. What am I missing here? Why does anyone need an entire button dedicated to disabling another, unrelated button? Why can’t I make it do something useful?
+
+Mail
+
+For the moment I decided for Thunderbird for mail, contacts and calendars (more about those later), and it was easy enough to set up for mail. I’d much prefer something which looks and works like mac os Mail, but installing the Conversation extension went a long way to making it usable (despite not always finding all messages in a thread for some reason).
+
+Music
+
+For the moment I chose Quod Libet as a basic iTunes replacement. It successfully scanned the contents of Music/iTunes/iTunes Media/Music with no complaints, and even played the AAC m4a files after I installed kubuntu-restricted-extras. Unfortuantely Quod Libet (and every other media player I tried) seems to be unable to inhibit sleep under Wayland — hopefully this will be remedied soon, as the “create a NoSleep activity and switch to it whenever you want to play music” ““workaround”” is not particularly appealing. I’d also settle for a status bar widget which let me switch power profiles quickly.
+
+Photos
+
+Moving my photo library took a little more effort, but not much, thanks to osxphotos. Additionally installing exiftools and then running one command created a structured export of my entire library, with all the metadata I care about stored safely in EXIF fields:
+
+osxphotos export /Volumes/migration/photos --directory "{created.year}/{created.mm}" --filename "{created}T{created.hour}{created.min}{created.sec}{title?_,}{title,}" --skip-original-if-edited --jpeg-ext jpeg --exiftool
+
+
+This command takes the edited version of each file (falling back to the original), and stores them in a /YYYY/MM/YYYY-MM-DDTHHMMSS[_title].jpeg folder structure, which is my preferred way of organising photos on disk.
+
+I then imported this library into DigiKam, which quickly read all the metadata and made everything searchable. To get newly imported photos to fit into the same structure, I had to go into the Import Settings (plug in a camera or card, go “Import from device” and then open the sidebar on the right — unfortunately these settings don’t seem to be exposed anywhere else) and set the default filename to be the datetime, and the default “Album” to be YYYY/mm.
+
+I’m not a huge fan of DigiKam, as it’s cluttered, unstable and requires some very akward workflows (editing images opens them in a separate window? adding a tag requires opening the “tag manager”?? “hierarchical tags”??? I think the developers did not understand what a tag is and what makes them useful) but will do for now. To ensure longevity (and ease migrating to a different management application if I find something better suited to my workflow) I opted to store all metadata in EXIF fields in the files themselves. This way, DigiKam’s external database works as an ephemeral index and cache, which I can throw away or rebuild at any time without losing anything.
+
+A useful tip I learned along the way (thanks to ChatGPT): exiftool -a -u -g1 <file_name> will list all EXIF data found in a given file.
+
+Calendars and Contacts
+
+I set up a Nextcloud instance on my web host to see how much of my (already limited) iCloud usage it could replace. Despite learning that Hostinger doesn’t allow access to the .well-known directory required for zero-config carddav and caldav setup, I successfully managed to get my calendar and contacts migrated there. Thunderbird was able to sync with both without any issues, and mac os Calendar did eventually read my calendars from Nextcloud. No such luck with mac os Contacts unfortunately, but that’s much lower priority than calendar anyway.
+
+Pages and Numbers documents
+
+I had hoped that there would be a way of easily and mostly-losslessly batch converting all my Pages and Numbers documents into their microsoft XML equivalents, before then converting them to Libreoffice documents later on. Alas, that is only partially true. I ended up modifying a script provided by Viking OSX, which finds all Pages documents in a given folder and exports them as word docs to a separate folder. My changes instead export them in-place, and additionally export a PDF version so that I have a lossless read-only copy of each document exactly as it was:
+
+#!/bin/zsh
+
+: <<"COMMENT"
+Do a recursive descent on a folder hierarchy gathering Pages document. Export these
+documents from Pages as Word .docx and .pdf documents in the same location.
+Tested: Ventura 13.0.1
+VikingOSX, 2022-12-06, Apple Support Communities, No implicit warranty or support.
+Adapted by Barnaby Walters 2023-09-08
+COMMENT
+
+typeset -gi pagesCnt=0 docxCnt=0
+
+STARTDIR=$1
+
+function pages_export () {
+
+ /usr/bin/osascript <<-AS
+ use scripting additions
+
+ tell application "Pages"
+ activate
+ try
+ set infile to POSIX file "${1}"
+ set outfile to POSIX file "${2}"
+ set outfile_pdf to POSIX file "${3}"
+
+ set thisDoc to open infile as alias
+
+ with timeout of 1200 seconds
+ export thisDoc to file outfile as Microsoft Word
+ end timeout
+ with timeout of 1200 seconds
+ export thisDoc to file outfile_pdf as PDF
+ end timeout
+ close thisDoc saving no
+ on error errmsg number errNo
+ display dialog "[ " & errNo & " ]: " & errmsg
+ end try
+ end tell
+ -- unhide the exported filename extensions
+ tell application "Finder"
+ if exists (item outfile as alias) then
+ set extension hidden of (item outfile as alias) to false
+ end if
+ end tell
+ return
+AS
+}
+
+function completion () {
+ /usr/bin/osascript <<-AS
+ use scripting additions
+
+ set DialogIcon to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MultipleItemsIcon.icns"
+
+ display dialog "Pages documents found: " & "${1}" & return & ¬
+ "Pages documents exported to Word and PDF docx: " & "${2}" with title "Processing Complete" with icon POSIX file DialogIcon
+ return
+AS
+}
+
+# do a case-insensitive recursion finding Pages documents and sorting by name
+setopt nocaseglob
+for f in ${STARTDIR}/**/*.pages(.Non);
+do
+ (( ++pagesCnt ))
+ # if there is no Word folder at this file location, then make one
+
+ # construct the full path to the word docx document to be exported
+ wordfile="${f:a:h:r}/${f:r:t}.docx"
+ pdffile="${f:a:h:r}/${f:r:t}.pdf"
+
+ pages_export "${f}" "${wordfile}" "${pdffile}"
+
+ # do we have an exported docx that is non-zero in size?
+ [[ -s $wordfile ]] && (( ++docxCnt ))
+done
+
+# give the user statistics
+completion $pagesCnt $docxCnt
+
+
+(aside: I initially tried to get ChatGPT to generate the necessary applescript to do this entire task for me, as I’d heard that it was good at that, and applescript is a notoriously unintuitive and badly documented language. It seemd to get fairly close but I was unable to debug the (incomprehensible) errors in its scripts. The approach taken by VikingOSX is much more efficient: use applescript only for the things it’s absolutely necessary for, and do the rest in bash or python)
+
+I did the same thing for Numbers documents, the necessary script changes for that are left as an exercise for the reader.
+
+Unfortunately, these exports (and/or their subsequent imports into Libreoffice) were not very successful except for the simplest of documents. I only actively use a total of maybe 5 documents, which I will simply reconstruct from scratch in Libreoffice, and for the rest a combination of lossless read-only PDF and potentially-broken Office XML files should be sufficient.
+
+Prusa Slicer, AppImages and KDE Plasma LC_ALL issues
+
+The official way of installing Prusa Slicer on linux is using an AppImage, a format which I’ve had mixed experiences with. This was no different, as opening it in Dolphin had no result. Opening it in a console revealed some sort of locale error, and suggested some commands to fix it, but they also had no effect.
+
+After doing some digging, it turns out that it’s KDE Plasma’s fault. Plasma splits your localization settings up into various categories (language, time format, currency etc.) — an excellent feature by itself. Unfortunately, if you pick different locales for any of these categories, it leave the LC_ALL environment variable empty.
+
+The Prusa Slicer AppImage (and who knows what other software) was expecting an LC_ALL environment variable, and refused to run without it. tl;dr, editing /etc/defaults/locale to set LC_ALL and LANG to en_GB.utf-8 allowed PS to run, without having caused any other issues (yet…?).
+
+Once it managed to run, Prusa Slicer somehow told the system about itself in a way which lets me launch it from the application launcher (not something every AppImage does), and worked absolutely fine. Importing my settings as a config bundle worked perfectly.
+
+Documents and file syncing
+
+For the moment I decided against trying to set up two-way sync of my ~50GB documents folder between os x and Kubuntu. Nextcloud on my cheap web host is out of the question, and Syncthing look promising but I’d want to test its limitations and performance on something smaller first. For the moment, I decided to just use rsync for a one-way migration, and can repeat it in the future as I convert more proprietary files to linux-compatible formats.
+
+rsync -avzu --exclude venv --exclude .DS_Store --exclude .h5 Documents/ slimbook:Documents
+
+
+venv and .h5 files are excluded to avoid transferring another ~30GB of unnecessary data. For syncronization after the first one, I need to make sure that rsync isn’t going to delete or replace newer files, but I will figure that out when I get to it. -u makes sure that files which are newer (i.e. made or changed) on the kubuntu side are not overwritten on subsequent syncs
+
+Pain points and next steps
+
+
+- DigiKam seems powerful but its UI kinda sucks
+- Plasma is great but has some drawbacks which will hopefully be fixed Soon™
+- Notes — I’m a heavy mac os Notes user, and have fairly high standards for its replacement. Nextcloud notes looks promising, but the iOS app has two editor modes: one which is fast but sucks, and another which is good but takes ~7s to load each note.
+- Converting proprietary file formats to their linux equivalents. I have some old Sketch documents and a LOT of Eazydraw documents, all of which need converting losslessly and perfectly to well-structured SVGs for use with inkscape, before I can switch completely to Kubuntu for work tasks. I had hoped to use a similar Applescript trick, but haven’t been able to figure it out yet as Eazydraw lacks an applescript interface. Using System Events to manually manipulate the menus could work, but seems fiddly
+- …
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ Notes from the first day using a Slimbook Executive running Kubuntu (probably applies to anyone moving from macos to Kubuntu on similar hardware)
+
+
+
+Generally, very good first impressions. The hardware is nice, the connectivity is perfect for me, it boots fast, the screen looks amazing. The keyboard and trackpad are fine, except for the surfboard trackpad button design. Came with a bunch of stupid marketing stickers on (what year is this, 2005?), most of which were easily removed.
+
+Here are the first settings I tweaked to make things more familiar:
+
+UI Scaling
+
+Settings -> Display and Monitor -> Global Scale = 200% for a readable UI while still remaining beautifully crisp.
+
+Settings -> Appearance -> Cursors -> Size: 48
+
+Settings -> Startup and Shutdown -> Login Screen -> Apply Plasma Settings so that your login screen is a sensible size.
+
+Right click status bar, enter edit mode, Panel height: 100
+
+Sleep
+
+Default sleep mode seems to be a hibernation which takes 10-20s to wake up from, including whenever you close the lid.
+
+Fix this by: In settings -> Power Management, in AC Powered tab set lid close to just turn off screen (or lock if desired). This will just turn off the screen when closed on AC power, but actually put the laptop to sleep when the lid is closed on battery power, to reduce power consumption.
+
+Then, sudo nano /etc/systemd/sleep.conf and uncomment AllowSuspendThenHibernate=yes, and reboot. This changes the behaviour of sleep to initially just suspend the system, keeping data in RAM and allowing immediate wake-ups. When the battery goes under 5%, it’ll instead hibernate, which takes 10-20s to wake up from but stores the contents of RAM on the SSD.
+
+EDIT: On further testing, this sadly doesn’t fix the issue completely (or at all? It’s hard to tell). Putting the computer to sleep using the meta menu works absolutely fine, but using F1 or the laptop lid (which I assume are handled the same way internally) leads to this blank screen with a cursor and hidden password entry field for 20s on wake up issue. I have no idea what’s causing it, and IMO it’s a big reason not to use KDE Plasma on these laptops — sadly, as it’s easily my favourite of the linux desktop environments I’ve tried so far.
+
+FURTHER EDIT: turns out this was all due to the laptop coming with an outdated linux kernel installed, which didn’t support the hardware. A fresh install of the latest Kubuntu works perfectly.
+
+Firefox
+
+By default, Firefox treats scroll events from the trackpad as scroll wheel inputs, causing jerky scrolling. To fix: echo MOZ_USE_XINPUT2=1 | sudo tee -a /etc/environment
+
+Touchpad
+
+Settings -> Input Devices -> Touchpad
+Pointer acceleration: 0.6
+Tap-to-click, tap-and-drag enabled
+Two-finger tap: right click
+Scrolling: two fingers, invert scroll direction
+Right click: press anywhere with two fingers
+
+Function Buttons
+
+Boot holding F2 to open BIOS settings, dig around to find and enable “Fn lock” to make the function keys perform their alternative functions by default (with numbered function inputs available by holding Fn, as on a MacBook)
+
+
+
+Next pain points which I didn’t find a solution to yet:
+
+
+- Occasional trackpad issues where the cursor freezes and only starts moving again after a two finger tap (right click). At the beginning this happened all the time, now it seems much better. Need to keep an eye on it.
+- File browser not having a column view. Apparently this is an ongoing struggle for years in Kubuntu, which seems hard to believe. I tried to install the ElementaryOS file viewer but it didn’t seem to work.
+- Setting up the keyboard for international typing. I got extremely used to typing special characters, diacritics and fancy punctuation on my macbook keyboard and am reluctant to have to re-learn all of that. Ideally I’d like to get a least a large subset of the key combinations working again.
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ CityNatureChallenge 2023 Wien Notable Observations
+
+
+ Vienna’s 2023 City Nature Challenge had more observers, observations and species than last year, and many observations still need final IDs. Here’s some of the more notable ones.
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ I’m a couple of weeks into 3D printing with a Creality Ender 3 S1 Pro. My initial impressions are: tl;dr: mechanically good, firmware bad. Either install synman’s pro firmware (requires a screen downgrade) or klipper (drops the screen and requires a raspberry pi — I went with MainsailOS) and you’ll have a very good printer for the price.
+
+Here’s my best 3D Benchy so far, printed in 55 minutes in PETG using Klipper
+
+
+Pros:
+
+
+- Mechanically solid and well built, comes very well packed, does not feel like the stereotypical “cheap chinese” product at all
+- Quick and easy to assemble (I recommend using loctite on all screws to prevent them coming loose from vibrations)
+- Some replacement parts available
+- Well supported with (mostly quite good) profiles available for various pieces of software
+- Touchscreen interface is fast and convenient to use if you’re satisfied with the stock firmware
+- Main board is not locked-down so it’s easy to install different firmware, and just as easy to revert to stock in the unlikely event that you want to
+
+
+Cons:
+
+
+- The stock firmware is very limited and has various problems.
+
+
+- Most notably, the “print on resume” feature causes uncontrollable pauses between layers, during which the nozzle will leak filament, causing huge blobs and stringing. Not possible to turn off in the UI, requires a
M413 S0 command added to the start g-code in your slicer (or changing to a different firmware, which you should do anyway). Here’s a comparison of the exact same part with and without “resume on power loss” enabled, both printed back when I was using the stock firmware: 
+- The auto bed leveling feels extremely unreliable and hard to trust
+- You can only see the first few characters of gcode files, so it’s impossible to differentiate between two similar files with different suffixes
+
+- Fiddly to perform firmware updates — screen and main board require separate files, sometimes in different folders depending on the chipset you have (which you can only check by opening the printer and looking at the hard-to-read MCU part number), always with a new filename otherwise it’ll fail silently, both will accept firmwares for different models with weird failure modes like a rotated screen
+- v-wheels riding in aluminium extrusions have a limited accuracy. Definitely good enough for a lot of purposes, but can warp and wear over time, will never be as good as precision-ground linear rods or (even better,) rails
+- XZ gantry arrived with loose Z nuts, causing huge amounts of Z kickback and preventing any kind of accurate movement. No indication that you have to tighten these in the instructions, and sources on the web inconsistent about what you should do about it. I ended up tightening mine up so they don’t rattle and have had no further issues.
+- Flex cable XZ clip position sticker was placed slightly wrong and awkward to adjust once in, and the flex cable end at the extruder requires better stress relief IMO. I added ~6cm of heatshrink tubing around it which works great
+- The provided slicer is horrible, I only tried it out to see if it’d fix my z blobbing problems. Fortunately Prusa Slicer works great with these printers
+
+
+I tuned mine up with the usual tools until I was satisfied with the prints using the stock firmware. Then I installed klipper and set up pressure advance and input shaping, vastly improving performance and usability.
+
+20mm calibration cubes printed 1) on the stock firmware, 2) Klipper with a speed profile, and 3) Klipper with a detail profile (i.e. slower outer perimeters):
+
+
+
+Here’s my current Prusa Slicer config files for the printer itself (Klipper) and my 0.16mm layer height optimal speed print profile.
+
+Here’s what my Klipper START_PRINT and END_PRINT macros ended up looking like:
+
+
+[gcode_macro START_PRINT]
+gcode:
+ {% set TOTAL_LAYER_COUNT = params.TOTAL_LAYER_COUNT|int %}
+ {% set BED_TEMP = params.BED_TEMP|float %}
+ {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|float %}
+
+SET_PRINT_STATS_INFO TOTAL_LAYER={TOTAL_LAYER_COUNT}
+ G90 ; use absolute coordinates
+ M83 ; extruder relative mode
+ M140 S{BED_TEMP} ; set final bed temp
+ M104 S{EXTRUDER_TEMP - 90} ; set temporary nozzle temp to prevent oozing during homing and auto bed leveling
+ G4 S10 ; allow partial nozzle warmup
+ G28 ; home all axis
+ M190 S{BED_TEMP} ; wait for bed temp to stabilize so that the bed mesh is accurate
+ BED_MESH_CALIBRATE
+ M104 S{EXTRUDER_TEMP} ; set final nozzle temp
+ G1 Z50 F240
+ G1 X2 Y10 F3000
+ M109 S{EXTRUDER_TEMP} ; wait for nozzle temp to stabilize
+ G1 Z0.28 F240
+ G92 E0
+ G1 Y140 E10 F1500 ; prime the nozzle
+ G1 X2.3 F5000
+ G92 E0
+ G1 Y10 E10 F1200 ; prime the nozzle
+ G92 E0
+
+[gcode_macro END_PRINT]
+gcode:
+ M140 S0 ; turn off heatbed
+ M104 S0 ; turn off temperature
+ M107 ; turn off fan
+ # Move nozzle away from print while retracting
+ G91
+ G1 X-2 Y-2 E-3 F300
+ # Raise nozzle by 10mm
+ G1 Z10 F3000
+ # Move out of the way
+ G90
+ G0 X20 Y150
+ # Disable steppers
+ M84 X Y E
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ From now on I will be making all reaction rolls with this die
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Mf2/waterpigs.co.uk_photo.jpg b/tests/Mf2/waterpigs.co.uk_photo.jpg
new file mode 100644
index 0000000..e0f436f
Binary files /dev/null and b/tests/Mf2/waterpigs.co.uk_photo.jpg differ
TITLE
@@ -1028,6 +1113,7 @@ public function testInvalidNestedPropertiesIgnored2() { $output = Mf2\parse($input); # `properties` should have length=3 + $this->assertIsArray($output['items'][0]['properties']); $this->assertEquals(3, count($output['items'][0]['properties'])); # should have these properties diff --git a/tests/Mf2/PlainTextTest.php b/tests/Mf2/PlainTextTest.php index 0bcdd3e..c78bb80 100644 --- a/tests/Mf2/PlainTextTest.php +++ b/tests/Mf2/PlainTextTest.php @@ -1,5 +1,7 @@ parse(); $entryProperties = $output['items'][0]['properties']; + $this->assertIsArray($entryProperties); $this->assertEquals($pName, $entryProperties['name'][0]); $this->assertEquals($eValue, $entryProperties['content'][0]['value']); $this->assertEquals($eHtml, $entryProperties['content'][0]['html']); } - public function aaronpkExpectations() { + /** + * @return arrayHello World
aaronpk_tv

-
+
-
+
+
+ ++ ++++ + + +New corollary to the 2010s classic snarky programmer adage “the cloud is someone else’s computer”:
+ +“AI is someone else’s GPU”
+ +from which it follows that
+ +“I’m starting a new company with
+ +AIsomeone else’s GPU”“I spent hours talking to
+ +AIsomeone else’s GPU about my life andthe AIsomeone else’s GPU told me to break up with my boyfriend”“I’m worried that my job is in danger of being replaced by
+ +AIsomeone else’s GPU““It’s crazy what convincing images
+ +AIsomeone else’s GPU can generate these days!” (okay, that one doesn’t sound so far-fetched)“Users expect our product to have advanced features and integration with
+ +AIsomeone else’s GPU”“
+ + +AIsomeone else’s GPU is the defining technology of the decade, if not the century”
+ -
+
+
+ + +
+ -
+
+
+ ++ ++++ + + +Here’s a KDE Plasma service menu (dolphin context menu action) for creating a valid CACHEDIR.TAG file in the selected folder. Useful for excluding things from being backed up! (e.g. via restic with the
+ +--exclude-cachesoption)
+ +[Desktop Entry] +Type=Service +MimeType=inode/directory +Actions=create_cachedir_tag + +[Desktop Action create_cachedir_tag] +Name=Create CACHEDIR.TAG +Icon=breeze/actions/22/document-edit-encrypt +Exec=echo "Signature: 8a477f597d28d172789f06886806bc55" > %u/CACHEDIR.TAG +Put it somewhere like
.local/share/kio/servicemenus/cachedir-tag.desktop, make it executable and it should show up in your context menu.
+ -
+
+
+ ++ ++++ + + +At the time of writing, due to a packaging mess-up, the builds of SDR++ (and many other SDR tools by the looks of it) have suddenly and unintentionally dropped support for the popular RTL-SDR software defined radio dongle. Until this is fixed, users will have to build these applications themselves. The instructions are a little lacking in details, so here’s exactly how to do that, working on Kubuntu:
+ +++# To install: +sudo aptitude install cmake libfftw3-dev libglfw3-dev libvolk-dev zstd libairspy-dev librtlsdr-dev +git clone https://github.com/AlexandreRouma/SDRPlusPlus.git +cd SDRPlusPlus +mkdir build +cd build +cmake .. +make -j5 # 5 is the number of threads to use for building. adjust to your preference +sh ../create_root.sh +sudo make install + +# To run: +sdrpp +
+
+ -
+
+
+ ++ ++++ + + +Reddit recently underwent another new, unpopular redesign, meaning that there are now three different UIs for accessing the website. Out of habit I would look at new-new reddit before remembering to switch to old-new reddit, and quickly noticed that looking at new-new reddit causes my laptop’s fans instantly start spinning.
+ +Here’s a firefox performance profile for 20-30s of each iteration of the reddit homepage. I simply loaded the page and did absolutely nothing.
+ +old.reddit.com: constant ~5% CPU usage with occasional spikes up to ~90%
+ +
+ +
new.reddit.com: usually 0% CPU usage with occasional bursts up to ~50%
+ +
+ +
reddit.com (new-new reddit): constant 30% CPU usage with occasional spikes even higher
+ +
+ +
I don’t have the time or knowledge required to dig into the performance profiler but I would be fascinated to know how old-new reddit ended up more efficient than old-old reddit, and exactly what new-new reddit is doing with 30% of my CPU??
+ + +
+ -
+
+
+ ++ ++++ + + +When importing photos into DigiKam, I want them to be renamed based on the ISO8601 datetime they were taken, ideally to millisecond precision to avoid conflicts when multiple images were taken in a single second. This has the nice side-effect that photos from multiple camera sources are guaranteed to be displayed in the correct order when browsing files, which is important and practical for me.
+ +I started out using this custom file renaming template on import:
+ +
+ +[date:"yyyy-MM-ddTHHMMss"]-[file] +as DigiKam’s
+ +[date]placeholder didn’t have an option for milliseconds, and I couldn‘t find a counter option which could handle my desired “append-#per-collision if this renaming scheme results in collisions”, so ended up just adding the entire camera-generated filename to the end.Unfortunately, this led to my files all being in the wrong order, even from the same camera. I haven’t quite figured out why, but it seems that there are several different internal datetime values stored in the image files: file creation date (which is completely wrong), the values used in DigiKam’s
+ +[date]templates (which are mostly wrong), and theDateTimeOriginalvalues stored in Exif data, which are not only correct but provide sub-second resolution too!So here’s the DigiKam import naming template which I will be using going forward:
+ +
+ +[meta:Exif.Photo.DateTimeOriginal]{range:1,10}{replace:":","-"}T[meta:Exif.Photo.DateTimeOriginal]{range:12,}{replace:":",""}s[meta:Exif.Photo.SubSecTimeOriginal] +which produces ISO8601-ish filenames like this:
+ +
+ +2023-06-16T143139s922.JPG +Broken down,
+ +
+ +[meta:Exif.Photo.DateTimeOriginal] +evalulates to a string like
+ +
+ +2023:06:16 14:31:39 +but I don’t want colons in filenames for portability, so I take only the date part with
+ + +{range:1,10}, replace the colons with hyphens{replace:":","-"}, add a literal T separator to avoid spaces in filenames, take the time part of the datetime and remove the colons completely, add a literal s separator to delimit seconds and milliseconds as I wanted to keep them separate but not use the typical . delimiter.
+ -
+
+
+ ++ ++++ + + +Ended up getting frustrated with the old version of DigiKam available on Kubuntu, so tried installing an AppImage. The state of AppImage integration with Kubuntu is abysmal, and I open DigiKam fairly regularly, so I finally tried installing AppImageLauncher, which is recommended by DigiKam and is supposed to be a good tool for integrating AppImages with the desktop environment (something which Plasma should surely do itself, if AppImages are really going to be part of the future of linux app packaging).
+ +Unfortunately, installing AppImageLauncher completely broke my desktop environment, causing it to hang and preventing me from logging in. Looked it up and it was clearly related to whatever this issue is about, as moving
+ +.local/share/mimefixed it. Removing AppImageLauncher and the mime cache got things working again, and, lo, before it broke my system, AppImageLauncher had kindly made.desktopfiles for all my AppImages!At this point I decided to take a more manual approach to integrating AppImages I cared about with my DE, so I added a link from
+ +~/Applications(where I store AppImages and other applications not installed via the package manager) to~/.local/share/applications, where.desktopfiles are kept. Having quick access to this location makes manually managing.desktopfiles much more bearable, and I went about improving the ones AppImageLauncher had made (e.g. adding version numbers to the names – I find it very useful to know what version of an app I’m launching).So, back to DigiKam: at this point I had a DigiKam 8.3 AppImage installed and openable via launchers thanks to the
+ +.desktopfile. It had to re-download the facial recognition files, but other than that picked up everything from before. However, in the main photo list view, the maximum size of the thumbnails was tiny.I spent some time poking around in settings and tweaking the QT scaling factor via the .desktop file, but I’ll spare you the details. tl;dr: if you want the DigiKam 8.3 AppImage to let you see large thumbnails on a high-DPI screen, you need to check the following boxes:
+ +-
+
- Miscellaneous → System → Use high DPI scaling from the screen factor +
- Vews → Icons → Use large thumbnail size for high screen resolution +
Restart DigiKam, and it should let you make thumbnails large enough to be useful. This is especially necessary seeing as how DigiKam’s photo list view has a horribly wasteful layout, with almost as much whitespace as photo surface area.
+ + +
+ -
+
+
+ ++ ++++ + + +If you run into weird “file corrupt or unwritable” errors when trying to tag/rename tracks with Picard on (k)ubuntu, check whether the files are read-only. When using Dolphin to rip and encode CDs (an excellent feature – Dolphin continues to surprise me) it retains their read-only permissions when copying them to your disk, rather than setting it to something sensible.
+ + +
+ -
+
+
+ ++ ++++ + + +Drew ferris with a soldering iron as I couldn‘t find much embedded rust art
+ +
+
+
+ -
+
+
+ ++ ++++ + + +Some tips for using Teensy on linux:
+ +The teensy board support package is only supported in the Arduino applications downloaded directly from the arduino site, NOT on versions distributed by package managers. I used the AppImage and it worked fine. If you try to install the teensy board package on an unsupported version of Arduino you might see errors like “archive not supported”.
+ +Even when you have a supported version of Arduino installed, installing the Teensy board package isn’t totally reliable. The first time I downloaded it, compiling would fail with the following error:
+ +
+ +fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory + +Compilation error: fork/exec /home/barnaby/.arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/arm-none-eabi-g++: no such file or directory +The 11.3.1 folder existed, but was empty. Down- then upgrading the board package didn‘t fix it. Removing the board package and reinstalling it did work.
+ + +
+ -
+
+
+ ++ ++++ + + +If you’re getting the following error in Inkscape on (k)ubuntu when trying to open the Extension Manager:
+ +
+ +[long traceback snipped] +ModuleNotFoundError: No module named 'appdirs' +the best way to deal with it seems to be
+ + +sudo apt install python3-appdirs, as trying to install theappdirsmodule withpiporpip3might not put it in the right place for the system python3 which inkscape is using, especially if you use something like conda or pyenv.
+ -
+
+
+ ++ ++++ + + +In a world where even “digital-natives” increasingly don’t understand basic file management, and where it’s more and more common for user data to be siloed per-app even on desktops, I propose a corollary to Zawinski’s Law: “All apps which don’t store data transparently in the file system are doomed to implement their own limited and fragile filesystem equivalent”
+
+ -
+
+
+ ++ ++++ + + +If you’re in the unfortunate position of needing to use MuseScore4 on linux for some reason (for example to use its excellent MIDI to notation conversion) and are having issues with the Flatpak version having an unreadably tiny UI on high-DPI screens, here’s how to fix it.
+ +Open the .desktop file for MuseScore 4 – mine was in
+ +/var/lib/flatpak/app/org.musescore.MuseScore/current/active/export/share/applications/org.musescore.MuseScore.desktopFind the
+ +Execkey, and change the command to include--env=QT_SCALE_FACTOR=2. Mine ended up looking like this:
+ +Exec=/usr/bin/flatpak run --env=QT_SCALE_FACTOR=2 --branch=stable --arch=x86_64 --command=mscore --file-forwarding org.musescore.MuseScore @@ %F @@ +Save (you’ll need to enter your password, or to have launched the editor with
+ +sudo).Try launching MuseScore again. If you’re lucky, it’ll have a readable UI. If not, try restarting and launching it again — I haven’t found a way of successfully getting KDE to force-update all its .desktop files. Presumably there’s a cache somewhere? If anyone knows how to reliably do this, please let me know!
+ + +This should work for any Flatpak which uses QT, on any desktop environment which uses .desktop files. I really hope “UI Scale” becomes a standard per-application setting in the near future.
+ +EDIT: thanks to carmanaught on the KDE forums for this additional suggestion to copy the .desktop file to
~/.local/share/applicationsrather than editing it in-place, and for details about how to set up a service to watch this folder and clear the desktop file cache whenever it’s edited.
+ -
+
+ + + + ++++ + + +Macbook -> Kubuntu Slimbook update 2:
+ +After a brief dalliance with PopOS (which I liked well enough, but convinced me that I much prefer Plasma over Gnome), thanks to advice from someone on r/Kubuntu I discovered that most of my Kubuntu issues had been due to Slimbook delivering laptops with an old version of Kubuntu and the linux kernel on, which isn’t really compatible with their laptops (and I had foolishly assumed that the system software update would also update the kernel — not so) tl;dr: if you buy a Slimbook laptop and want to run Kubuntu on it, install it yourself!
+ +Desktop Environment
+ +After trying out Plasma on both X11 and Wayland, I decided to opt for sticking with Wayland, despite a few “showstoppers” and other minor annoyances. It has excellent support for a lot of quite slick features, such as fractional per-monitor UI scaling and multitouch gestures for switching virtual desktops (currently not yet configurable, hopefully this will change in the future).
+ +The current stable release of GIMP uses an old version of GTK which doesn’t scale well under Wayland, but fortunately the development release (2.99.16) has GTK3 support and the UI scales just fine.
+ +VLC also looks very weird under Plasma. I kept it around as it’s so useful, but also installed Celluloid 0.25.1 from their PPA as a potential Plasma-friendly replacement.
+ +Keyboards
+ +I type almost exclusively in ABC-Extended on my macbook, which gives me quick access to all the international characters I need access to, as well as some nice punctuation like en+em dashes, ellipses and curly quotes.
+ +I tried several keyboard layouts on my slimbook, and eventually settled for the English (Macintosh) one, which is almost the same with a few small differences. I will probably end up making my own keyboard layout which shifts some things around and replaces unused things with useful characters.
+ +For quick reference and learning different keyboard layouts, I recommend assigning this command to a global shortcut (I used ctrl+alt+shift+k), which brings up a keyboard preview, scaled to look good on my monitor. I haven’t found a good way of dismissing it other than using the trackpad (ideally I’d like it to only be displayed while I hold the shortcut), but it’s still very convenient.
+ +
+ +tastenbrett -qwindowgeometry 2500x850 +For some reason, my F2 button’s special feature is “toggle whether the super key is locked, without indicating the current status to the user at all”. Apparently this is a common feature, but some cursory research did not reveal why this would ever be useful, or what the intended use is. I also didn’t find many other people asking about it. What am I missing here? Why does anyone need an entire button dedicated to disabling another, unrelated button? Why can’t I make it do something useful?
+ +Mail
+ +For the moment I decided for Thunderbird for mail, contacts and calendars (more about those later), and it was easy enough to set up for mail. I’d much prefer something which looks and works like mac os Mail, but installing the Conversation extension went a long way to making it usable (despite not always finding all messages in a thread for some reason).
+ +Music
+ +For the moment I chose Quod Libet as a basic iTunes replacement. It successfully scanned the contents of
+ +Music/iTunes/iTunes Media/Musicwith no complaints, and even played the AAC m4a files after I installed kubuntu-restricted-extras. Unfortuantely Quod Libet (and every other media player I tried) seems to be unable to inhibit sleep under Wayland — hopefully this will be remedied soon, as the “create a NoSleep activity and switch to it whenever you want to play music” ““workaround”” is not particularly appealing. I’d also settle for a status bar widget which let me switch power profiles quickly.Photos
+ +Moving my photo library took a little more effort, but not much, thanks to osxphotos. Additionally installing exiftools and then running one command created a structured export of my entire library, with all the metadata I care about stored safely in EXIF fields:
+ +
+ +osxphotos export /Volumes/migration/photos --directory "{created.year}/{created.mm}" --filename "{created}T{created.hour}{created.min}{created.sec}{title?_,}{title,}" --skip-original-if-edited --jpeg-ext jpeg --exiftool +This command takes the edited version of each file (falling back to the original), and stores them in a
+ +/YYYY/MM/YYYY-MM-DDTHHMMSS[_title].jpegfolder structure, which is my preferred way of organising photos on disk.I then imported this library into DigiKam, which quickly read all the metadata and made everything searchable. To get newly imported photos to fit into the same structure, I had to go into the Import Settings (plug in a camera or card, go “Import from device” and then open the sidebar on the right — unfortunately these settings don’t seem to be exposed anywhere else) and set the default filename to be the datetime, and the default “Album” to be
+ +YYYY/mm.I’m not a huge fan of DigiKam, as it’s cluttered, unstable and requires some very akward workflows (editing images opens them in a separate window? adding a tag requires opening the “tag manager”?? “hierarchical tags”??? I think the developers did not understand what a tag is and what makes them useful) but will do for now. To ensure longevity (and ease migrating to a different management application if I find something better suited to my workflow) I opted to store all metadata in EXIF fields in the files themselves. This way, DigiKam’s external database works as an ephemeral index and cache, which I can throw away or rebuild at any time without losing anything.
+ +A useful tip I learned along the way (thanks to ChatGPT):
+ +exiftool -a -u -g1 <file_name>will list all EXIF data found in a given file.Calendars and Contacts
+ +I set up a Nextcloud instance on my web host to see how much of my (already limited) iCloud usage it could replace. Despite learning that Hostinger doesn’t allow access to the .well-known directory required for zero-config carddav and caldav setup, I successfully managed to get my calendar and contacts migrated there. Thunderbird was able to sync with both without any issues, and mac os Calendar did eventually read my calendars from Nextcloud. No such luck with mac os Contacts unfortunately, but that’s much lower priority than calendar anyway.
+ +Pages and Numbers documents
+ +I had hoped that there would be a way of easily and mostly-losslessly batch converting all my Pages and Numbers documents into their microsoft XML equivalents, before then converting them to Libreoffice documents later on. Alas, that is only partially true. I ended up modifying a script provided by Viking OSX, which finds all Pages documents in a given folder and exports them as word docs to a separate folder. My changes instead export them in-place, and additionally export a PDF version so that I have a lossless read-only copy of each document exactly as it was:
+ +
+ +#!/bin/zsh + +: <<"COMMENT" +Do a recursive descent on a folder hierarchy gathering Pages document. Export these +documents from Pages as Word .docx and .pdf documents in the same location. +Tested: Ventura 13.0.1 +VikingOSX, 2022-12-06, Apple Support Communities, No implicit warranty or support. +Adapted by Barnaby Walters 2023-09-08 +COMMENT + +typeset -gi pagesCnt=0 docxCnt=0 + +STARTDIR=$1 + +function pages_export () { + + /usr/bin/osascript <<-AS + use scripting additions + + tell application "Pages" + activate + try + set infile to POSIX file "${1}" + set outfile to POSIX file "${2}" + set outfile_pdf to POSIX file "${3}" + + set thisDoc to open infile as alias + + with timeout of 1200 seconds + export thisDoc to file outfile as Microsoft Word + end timeout + with timeout of 1200 seconds + export thisDoc to file outfile_pdf as PDF + end timeout + close thisDoc saving no + on error errmsg number errNo + display dialog "[ " & errNo & " ]: " & errmsg + end try + end tell + -- unhide the exported filename extensions + tell application "Finder" + if exists (item outfile as alias) then + set extension hidden of (item outfile as alias) to false + end if + end tell + return +AS +} + +function completion () { + /usr/bin/osascript <<-AS + use scripting additions + + set DialogIcon to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MultipleItemsIcon.icns" + + display dialog "Pages documents found: " & "${1}" & return & ¬ + "Pages documents exported to Word and PDF docx: " & "${2}" with title "Processing Complete" with icon POSIX file DialogIcon + return +AS +} + +# do a case-insensitive recursion finding Pages documents and sorting by name +setopt nocaseglob +for f in ${STARTDIR}/**/*.pages(.Non); +do + (( ++pagesCnt )) + # if there is no Word folder at this file location, then make one + + # construct the full path to the word docx document to be exported + wordfile="${f:a:h:r}/${f:r:t}.docx" + pdffile="${f:a:h:r}/${f:r:t}.pdf" + + pages_export "${f}" "${wordfile}" "${pdffile}" + + # do we have an exported docx that is non-zero in size? + [[ -s $wordfile ]] && (( ++docxCnt )) +done + +# give the user statistics +completion $pagesCnt $docxCnt +(aside: I initially tried to get ChatGPT to generate the necessary applescript to do this entire task for me, as I’d heard that it was good at that, and applescript is a notoriously unintuitive and badly documented language. It seemd to get fairly close but I was unable to debug the (incomprehensible) errors in its scripts. The approach taken by VikingOSX is much more efficient: use applescript only for the things it’s absolutely necessary for, and do the rest in bash or python)
+ +I did the same thing for Numbers documents, the necessary script changes for that are left as an exercise for the reader.
+ +Unfortunately, these exports (and/or their subsequent imports into Libreoffice) were not very successful except for the simplest of documents. I only actively use a total of maybe 5 documents, which I will simply reconstruct from scratch in Libreoffice, and for the rest a combination of lossless read-only PDF and potentially-broken Office XML files should be sufficient.
+ +Prusa Slicer, AppImages and KDE Plasma LC_ALL issues
+ +The official way of installing Prusa Slicer on linux is using an AppImage, a format which I’ve had mixed experiences with. This was no different, as opening it in Dolphin had no result. Opening it in a console revealed some sort of locale error, and suggested some commands to fix it, but they also had no effect.
+ +After doing some digging, it turns out that it’s KDE Plasma’s fault. Plasma splits your localization settings up into various categories (language, time format, currency etc.) — an excellent feature by itself. Unfortunately, if you pick different locales for any of these categories, it leave the LC_ALL environment variable empty.
+ +The Prusa Slicer AppImage (and who knows what other software) was expecting an LC_ALL environment variable, and refused to run without it. tl;dr, editing
+ +/etc/defaults/localeto set LC_ALL and LANG to en_GB.utf-8 allowed PS to run, without having caused any other issues (yet…?).Once it managed to run, Prusa Slicer somehow told the system about itself in a way which lets me launch it from the application launcher (not something every AppImage does), and worked absolutely fine. Importing my settings as a config bundle worked perfectly.
+ +Documents and file syncing
+ +For the moment I decided against trying to set up two-way sync of my ~50GB documents folder between os x and Kubuntu. Nextcloud on my cheap web host is out of the question, and Syncthing look promising but I’d want to test its limitations and performance on something smaller first. For the moment, I decided to just use rsync for a one-way migration, and can repeat it in the future as I convert more proprietary files to linux-compatible formats.
+ +
+ +rsync -avzu --exclude venv --exclude .DS_Store --exclude .h5 Documents/ slimbook:Documents +venv and .h5 files are excluded to avoid transferring another ~30GB of unnecessary data.
+ +For syncronization after the first one, I need to make sure that rsync isn’t going to delete or replace newer files, but I will figure that out when I get to it.-u makes sure that files which are newer (i.e. made or changed) on the kubuntu side are not overwritten on subsequent syncsPain points and next steps
+ +-
+
- DigiKam seems powerful but its UI kinda sucks +
- Plasma is great but has some drawbacks which will hopefully be fixed Soon™ +
- Notes — I’m a heavy mac os Notes user, and have fairly high standards for its replacement. Nextcloud notes looks promising, but the iOS app has two editor modes: one which is fast but sucks, and another which is good but takes ~7s to load each note. +
- Converting proprietary file formats to their linux equivalents. I have some old Sketch documents and a LOT of Eazydraw documents, all of which need converting losslessly and perfectly to well-structured SVGs for use with inkscape, before I can switch completely to Kubuntu for work tasks. I had hoped to use a similar Applescript trick, but haven’t been able to figure it out yet as Eazydraw lacks an applescript interface. Using System Events to manually manipulate the menus could work, but seems fiddly +
- … +
+ -
+
+
+ ++ ++++ + + +Notes from the first day using a Slimbook Executive running Kubuntu (probably applies to anyone moving from macos to Kubuntu on similar hardware)
+ +
+ +
Generally, very good first impressions. The hardware is nice, the connectivity is perfect for me, it boots fast, the screen looks amazing. The keyboard and trackpad are fine, except for the surfboard trackpad button design. Came with a bunch of stupid marketing stickers on (what year is this, 2005?), most of which were easily removed.
+ +Here are the first settings I tweaked to make things more familiar:
+ +UI Scaling
+ +Settings -> Display and Monitor -> Global Scale = 200% for a readable UI while still remaining beautifully crisp.
+ +Settings -> Appearance -> Cursors -> Size: 48
+ +Settings -> Startup and Shutdown -> Login Screen -> Apply Plasma Settings so that your login screen is a sensible size.
+ +Right click status bar, enter edit mode, Panel height: 100
+ +Sleep
+ +Default sleep mode seems to be a hibernation which takes 10-20s to wake up from, including whenever you close the lid.
+ +Fix this by: In settings -> Power Management, in AC Powered tab set lid close to just turn off screen (or lock if desired). This will just turn off the screen when closed on AC power, but actually put the laptop to sleep when the lid is closed on battery power, to reduce power consumption.
+ +Then,
+ +sudo nano /etc/systemd/sleep.confand uncommentAllowSuspendThenHibernate=yes, and reboot. This changes the behaviour of sleep to initially just suspend the system, keeping data in RAM and allowing immediate wake-ups. When the battery goes under 5%, it’ll instead hibernate, which takes 10-20s to wake up from but stores the contents of RAM on the SSD.EDIT: On further testing, this sadly doesn’t fix the issue completely (or at all? It’s hard to tell). Putting the computer to sleep using the meta menu works absolutely fine, but using F1 or the laptop lid (which I assume are handled the same way internally) leads to this blank screen with a cursor and hidden password entry field for 20s on wake up issue. I have no idea what’s causing it, and IMO it’s a big reason not to use KDE Plasma on these laptops — sadly, as it’s easily my favourite of the linux desktop environments I’ve tried so far.
+ +FURTHER EDIT: turns out this was all due to the laptop coming with an outdated linux kernel installed, which didn’t support the hardware. A fresh install of the latest Kubuntu works perfectly.
+ +Firefox
+ +By default, Firefox treats scroll events from the trackpad as scroll wheel inputs, causing jerky scrolling. To fix:
+ +echo MOZ_USE_XINPUT2=1 | sudo tee -a /etc/environmentTouchpad
+ +Settings -> Input Devices -> Touchpad
+ +
+Pointer acceleration: 0.6
+Tap-to-click, tap-and-drag enabled
+Two-finger tap: right click
+Scrolling: two fingers, invert scroll direction
+Right click: press anywhere with two fingersFunction Buttons
+ +Boot holding F2 to open BIOS settings, dig around to find and enable “Fn lock” to make the function keys perform their alternative functions by default (with numbered function inputs available by holding Fn, as on a MacBook)
+ +
+ +Next pain points which I didn’t find a solution to yet:
+ +-
+
- Occasional trackpad issues where the cursor freezes and only starts moving again after a two finger tap (right click). At the beginning this happened all the time, now it seems much better. Need to keep an eye on it. +
- File browser not having a column view. Apparently this is an ongoing struggle for years in Kubuntu, which seems hard to believe. I tried to install the ElementaryOS file viewer but it didn’t seem to work. +
- Setting up the keyboard for international typing. I got extremely used to typing special characters, diacritics and fancy punctuation on my macbook keyboard and am reluctant to have to re-learn all of that. Ideally I’d like to get a least a large subset of the key combinations working again. +
+ -
+
+
+ + +
+ -
+
+ ++ CityNatureChallenge 2023 Wien Notable Observations +
+ +Vienna’s 2023 City Nature Challenge had more observers, observations and species than last year, and many observations still need final IDs. Here’s some of the more notable ones.+ + + ++ + + + +
+
+ -
+
+
+ ++ ++++ + + +I’m a couple of weeks into 3D printing with a Creality Ender 3 S1 Pro. My initial impressions are: tl;dr: mechanically good, firmware bad. Either install synman’s pro firmware (requires a screen downgrade) or klipper (drops the screen and requires a raspberry pi — I went with MainsailOS) and you’ll have a very good printer for the price.
+ +Here’s my best 3D Benchy so far, printed in 55 minutes in PETG using Klipper +
+ +
Pros:
+ +-
+
- Mechanically solid and well built, comes very well packed, does not feel like the stereotypical “cheap chinese” product at all +
- Quick and easy to assemble (I recommend using loctite on all screws to prevent them coming loose from vibrations) +
- Some replacement parts available +
- Well supported with (mostly quite good) profiles available for various pieces of software +
- Touchscreen interface is fast and convenient to use if you’re satisfied with the stock firmware +
- Main board is not locked-down so it’s easy to install different firmware, and just as easy to revert to stock in the unlikely event that you want to +
Cons:
+ +-
+
- The stock firmware is very limited and has various problems.
+
+
-
+
- Most notably, the “print on resume” feature causes uncontrollable pauses between layers, during which the nozzle will leak filament, causing huge blobs and stringing. Not possible to turn off in the UI, requires a
M413 S0command added to the start g-code in your slicer (or changing to a different firmware, which you should do anyway). Here’s a comparison of the exact same part with and without “resume on power loss” enabled, both printed back when I was using the stock firmware:
+ - The auto bed leveling feels extremely unreliable and hard to trust +
- You can only see the first few characters of gcode files, so it’s impossible to differentiate between two similar files with different suffixes +
+ - Most notably, the “print on resume” feature causes uncontrollable pauses between layers, during which the nozzle will leak filament, causing huge blobs and stringing. Not possible to turn off in the UI, requires a
- Fiddly to perform firmware updates — screen and main board require separate files, sometimes in different folders depending on the chipset you have (which you can only check by opening the printer and looking at the hard-to-read MCU part number), always with a new filename otherwise it’ll fail silently, both will accept firmwares for different models with weird failure modes like a rotated screen +
- v-wheels riding in aluminium extrusions have a limited accuracy. Definitely good enough for a lot of purposes, but can warp and wear over time, will never be as good as precision-ground linear rods or (even better,) rails +
- XZ gantry arrived with loose Z nuts, causing huge amounts of Z kickback and preventing any kind of accurate movement. No indication that you have to tighten these in the instructions, and sources on the web inconsistent about what you should do about it. I ended up tightening mine up so they don’t rattle and have had no further issues. +
- Flex cable XZ clip position sticker was placed slightly wrong and awkward to adjust once in, and the flex cable end at the extruder requires better stress relief IMO. I added ~6cm of heatshrink tubing around it which works great +
- The provided slicer is horrible, I only tried it out to see if it’d fix my z blobbing problems. Fortunately Prusa Slicer works great with these printers +
I tuned mine up with the usual tools until I was satisfied with the prints using the stock firmware. Then I installed klipper and set up pressure advance and input shaping, vastly improving performance and usability.
+ +20mm calibration cubes printed 1) on the stock firmware, 2) Klipper with a speed profile, and 3) Klipper with a detail profile (i.e. slower outer perimeters):
+ +
+ +
Here’s my current Prusa Slicer config files for the printer itself (Klipper) and my 0.16mm layer height optimal speed print profile.
+ +Here’s what my Klipper
+ +START_PRINTandEND_PRINTmacros ended up looking like:+[gcode_macro START_PRINT] +gcode: + {% set TOTAL_LAYER_COUNT = params.TOTAL_LAYER_COUNT|int %} + {% set BED_TEMP = params.BED_TEMP|float %} + {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|float %} + +SET_PRINT_STATS_INFO TOTAL_LAYER={TOTAL_LAYER_COUNT} + G90 ; use absolute coordinates + M83 ; extruder relative mode + M140 S{BED_TEMP} ; set final bed temp + M104 S{EXTRUDER_TEMP - 90} ; set temporary nozzle temp to prevent oozing during homing and auto bed leveling + G4 S10 ; allow partial nozzle warmup + G28 ; home all axis + M190 S{BED_TEMP} ; wait for bed temp to stabilize so that the bed mesh is accurate + BED_MESH_CALIBRATE + M104 S{EXTRUDER_TEMP} ; set final nozzle temp + G1 Z50 F240 + G1 X2 Y10 F3000 + M109 S{EXTRUDER_TEMP} ; wait for nozzle temp to stabilize + G1 Z0.28 F240 + G92 E0 + G1 Y140 E10 F1500 ; prime the nozzle + G1 X2.3 F5000 + G92 E0 + G1 Y10 E10 F1200 ; prime the nozzle + G92 E0 + +[gcode_macro END_PRINT] +gcode: + M140 S0 ; turn off heatbed + M104 S0 ; turn off temperature + M107 ; turn off fan + # Move nozzle away from print while retracting + G91 + G1 X-2 Y-2 E-3 F300 + # Raise nozzle by 10mm + G1 Z10 F3000 + # Move out of the way + G90 + G0 X20 Y150 + # Disable steppers + M84 X Y E +
+ -
+
+
+ ++ ++++ + + +From now on I will be making all reaction rolls with this die
+ +
+ -
+
+
+ + +
+
mention.tech
+
+ Barnaby Walters
