diff --git a/dev-tools.sh b/dev-tools.sh index d7573df..5868a6f 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -33,6 +33,6 @@ # stable version. # # Uncomment and set the Dev-Tools's commit value and commit this change. -# export GH_COMMIT=COMMIT_SHA + export GH_COMMIT=8d73b8a8a92856b78f7f66701e76e5e2e7be580d bash <(curl -L https://raw.githubusercontent.com/dpc-sdp/dev-tools/master/install?"$(date +%s)") "$@" diff --git a/src/TideSiteMenuAutocreate.php b/src/TideSiteMenuAutocreate.php index 5c681f4..437514f 100644 --- a/src/TideSiteMenuAutocreate.php +++ b/src/TideSiteMenuAutocreate.php @@ -2,7 +2,6 @@ namespace Drupal\tide_site; -use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; @@ -228,7 +227,7 @@ protected function getAssociatedMenu($menu_title, $tid) { */ protected static function filterAutocreateFieldNames($values) { return array_filter($values, function ($k) { - return Unicode::strpos($k, self::AUTOCREATE_FIELD_PREFIX) === 0 && Unicode::strpos($k, 'menu') !== FALSE; + return mb_strpos($k, self::AUTOCREATE_FIELD_PREFIX) === 0 && mb_strpos($k, 'menu') !== FALSE; }, ARRAY_FILTER_USE_KEY); } @@ -252,11 +251,11 @@ protected static function makeAutocreateFieldName($string) { * If provided string does not contain expected field prefix. */ protected static function extractMenuName($string) { - if (Unicode::strpos($string, self::AUTOCREATE_FIELD_PREFIX) === FALSE) { + if (mb_strpos($string, self::AUTOCREATE_FIELD_PREFIX) === FALSE) { throw new \Exception('Unable to extract menu name from provided value'); } - return Unicode::substr($string, Unicode::strlen(self::AUTOCREATE_FIELD_PREFIX)); + return mb_substr($string, mb_strlen(self::AUTOCREATE_FIELD_PREFIX)); } /** @@ -350,7 +349,7 @@ protected function makeMenuLabel($menu_title, $tid) { */ protected static function toMachineName($string, $delimiter = '_') { $string = trim($string); - $string = Unicode::strtolower($string); + $string = mb_strtolower($string); // Replace spaces and hyphens, preserving existing delimiters. $string = str_replace([$delimiter, ' ', '-', '_'], $delimiter, $string); // Remove all other non-alphanumeric characters. diff --git a/tests/src/Unit/TideSiteFieldsTest.php b/tests/src/Unit/TideSiteFieldsTest.php index 580b7ee..7278dea 100644 --- a/tests/src/Unit/TideSiteFieldsTest.php +++ b/tests/src/Unit/TideSiteFieldsTest.php @@ -17,8 +17,7 @@ class TideSiteFieldsTest extends TideSiteTest { * @dataProvider providerNormaliseFieldName */ public function testToMachineName($field_name, $entity_type_id, $bundle, $expected) { - $mock = self::createMock('Drupal\tide_site\TideSiteFields'); - $actual = $this->callProtectedMethod($mock, 'normaliseFieldName', [$field_name, $entity_type_id, $bundle]); + $actual = TideSiteFields::normaliseFieldName($field_name, $entity_type_id, $bundle); $this->assertEquals($expected, $actual); }