comparison core/modules/config/tests/src/Functional/ConfigEntityTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 7a779792577d
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\config\Functional; 3 namespace Drupal\Tests\config\Functional;
4 4
5 use Drupal\Component\Utility\SafeMarkup; 5 use Drupal\Component\Render\FormattableMarkup;
6 use Drupal\Core\Entity\EntityMalformedException; 6 use Drupal\Core\Entity\EntityMalformedException;
7 use Drupal\Core\Entity\EntityStorageException; 7 use Drupal\Core\Entity\EntityStorageException;
8 use Drupal\Core\Config\Entity\ConfigEntityStorage; 8 use Drupal\Core\Config\Entity\ConfigEntityStorage;
9 use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; 9 use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
10 use Drupal\Core\Url; 10 use Drupal\Core\Url;
145 $id_length_config_test = $storage->create([ 145 $id_length_config_test = $storage->create([
146 'id' => $this->randomMachineName(8), 146 'id' => $this->randomMachineName(8),
147 ]); 147 ]);
148 try { 148 try {
149 $id_length_config_test->save(); 149 $id_length_config_test->save();
150 $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [ 150 $this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
151 '@length' => strlen($id_length_config_test->id()), 151 '@length' => strlen($id_length_config_test->id()),
152 ])); 152 ]));
153 } 153 }
154 catch (ConfigEntityIdLengthException $e) { 154 catch (ConfigEntityIdLengthException $e) {
155 $this->fail($e->getMessage()); 155 $this->fail($e->getMessage());
159 $id_length_config_test = $storage->create([ 159 $id_length_config_test = $storage->create([
160 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), 160 'id' => $this->randomMachineName(static::MAX_ID_LENGTH),
161 ]); 161 ]);
162 try { 162 try {
163 $id_length_config_test->save(); 163 $id_length_config_test->save();
164 $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [ 164 $this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
165 '@length' => strlen($id_length_config_test->id()), 165 '@length' => strlen($id_length_config_test->id()),
166 ])); 166 ]));
167 } 167 }
168 catch (ConfigEntityIdLengthException $e) { 168 catch (ConfigEntityIdLengthException $e) {
169 $this->fail($e->getMessage()); 169 $this->fail($e->getMessage());
173 $id_length_config_test = $storage->create([ 173 $id_length_config_test = $storage->create([
174 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), 174 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1),
175 ]); 175 ]);
176 try { 176 try {
177 $status = $id_length_config_test->save(); 177 $status = $id_length_config_test->save();
178 $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [ 178 $this->fail(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [
179 '@length' => strlen($id_length_config_test->id()), 179 '@length' => strlen($id_length_config_test->id()),
180 '@max' => static::MAX_ID_LENGTH, 180 '@max' => static::MAX_ID_LENGTH,
181 ])); 181 ]));
182 } 182 }
183 catch (ConfigEntityIdLengthException $e) { 183 catch (ConfigEntityIdLengthException $e) {
184 $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [ 184 $this->pass(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
185 '@length' => strlen($id_length_config_test->id()), 185 '@length' => strlen($id_length_config_test->id()),
186 '@max' => static::MAX_ID_LENGTH, 186 '@max' => static::MAX_ID_LENGTH,
187 ])); 187 ]));
188 } 188 }
189 189