Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
update unit test and remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Apr 29, 2021
1 parent 1066848 commit 8a88cef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)") "$@"
9 changes: 4 additions & 5 deletions src/TideSiteMenuAutocreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions tests/src/Unit/TideSiteFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 8a88cef

Please sign in to comment.