X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Ffile_mdm%2Ffile_mdm_font%2Ftests%2Fsrc%2FKernel%2FFileMetadataFontTest.php;fp=web%2Fmodules%2Fcontrib%2Ffile_mdm%2Ffile_mdm_font%2Ftests%2Fsrc%2FKernel%2FFileMetadataFontTest.php;h=1cb24647e1475ce080ec25849bfd744780b086ba;hb=059867c3f96750652c80f39e44c442a58c2549ee;hp=0000000000000000000000000000000000000000;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2;p=yaffs-website diff --git a/web/modules/contrib/file_mdm/file_mdm_font/tests/src/Kernel/FileMetadataFontTest.php b/web/modules/contrib/file_mdm/file_mdm_font/tests/src/Kernel/FileMetadataFontTest.php new file mode 100644 index 000000000..1cb24647e --- /dev/null +++ b/web/modules/contrib/file_mdm/file_mdm_font/tests/src/Kernel/FileMetadataFontTest.php @@ -0,0 +1,114 @@ +installConfig(['file_mdm_font']); + } + + /** + * Test 'font' plugin. + */ + public function testFontPlugin() { + // The font files that will be tested. + $font_files = [ + [ + 'uri' => drupal_get_path('module', 'image_effects') . '/tests/fonts/LinLibertineTTF_5.3.0_2012_07_02/LinLibertine_Rah.ttf', + 'count_keys' => 15, + 'test_keys' => [ + ['Version', 'Version 5.3.0 ; ttfautohint (v0.9)'], + ['version', 'Version 5.3.0 ; ttfautohint (v0.9)'], + ['VeRsIoN', 'Version 5.3.0 ; ttfautohint (v0.9)'], + ['FontWeight', 400], + ], + ], + [ + 'uri' => drupal_get_path('module', 'image_effects') . '/tests/fonts/LinLibertineTTF_5.3.0_2012_07_02/LinBiolinum_Kah.ttf', + 'count_keys' => 15, + 'test_keys' => [ + ['FullName', 'Linux Biolinum Keyboard'], + ['fullname', 'Linux Biolinum Keyboard'], + ['fUlLnAmE', 'Linux Biolinum Keyboard'], + ], + ], + ]; + + $fmdm = $this->container->get('file_metadata_manager'); + + // Walk through test files. + foreach ($font_files as $font_file) { + $file_metadata = $fmdm->uri($font_file['uri']); + if (!$file_metadata) { + $this->fail("File not found: {$font_file['uri']}"); + continue; + } + $this->assertEqual($font_file['count_keys'], $this->countMetadataKeys($file_metadata, 'font')); + $this->assertIdentical(FileMetadataInterface::LOADED_FROM_FILE, $file_metadata->isMetadataLoaded('font')); + foreach ($font_file['test_keys'] as $test) { + $this->assertEqual($test[1], $file_metadata->getMetadata('font', $test[0])); + } + } + } + + /** + * Test 'font' plugin supported keys. + */ + public function testSupportedKeys() { + $expected_keys = [ + 'FontType', + 'FontWeight', + 'Copyright', + 'FontName', + 'FontSubfamily', + 'UniqueID', + 'FullName', + 'Version', + 'PostScriptName', + 'Trademark', + 'Manufacturer', + 'Designer', + 'Description', + 'FontVendorURL', + 'FontDesignerURL', + 'LicenseDescription', + 'LicenseURL', + 'PreferredFamily', + 'PreferredSubfamily', + 'CompatibleFullName', + 'SampleText', + ]; + + $fmdm = $this->container->get('file_metadata_manager'); + $file_md = $fmdm->uri(drupal_get_path('module', 'image_effects') . '/tests/fonts/LinLibertineTTF_5.3.0_2012_07_02/LinLibertine_Rah.ttf'); + $this->assertEqual($expected_keys, $file_md->getSupportedKeys('font')); + } + +}