The TypedDataTest has no need for being a web test. So let us switch it to a Drupal unit test.

Comments

corvus_ch’s picture

Status: Active » Needs review
StatusFileSize
new5.95 KB

And here comes the patch.

berdir’s picture

berdir’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.phpundefined
@@ -179,17 +209,17 @@ public function testGetAndSet() {
     // Binary type.
-    $typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->uri);
+    $typed_data = $this->createTypedData(array('type' => 'binary'), $image->uri);
     $this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.');
     $this->assertEqual($typed_data->validate()->count(), 0);
     // Try setting by URI.
-    $typed_data->setValue($files[1]->uri);
-    $this->assertEqual(is_resource($typed_data->getValue()), fopen($files[1]->uri, 'r'), 'Binary value was changed.');
+    $typed_data->setValue($image->uri);
+    $this->assertEqual(is_resource($typed_data->getValue()), fopen($image->uri, 'r'), 'Binary value was changed.');

This is using two different files to make sure that changing the value actually works.

So you probably need to create two images (can both be druplicon.png as source I think).

fago’s picture

Issue tags: +typed data
corvus_ch’s picture

Component: base system » typed data system
StatusFileSize
new4.54 KB

Next try.

corvus_ch’s picture

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Reviewed & tested by the community

This looks good. We can open a follow-up issue to split the huge class into multiple classes with more separate test methods so that it's more like a unit and not a web test. We can also add a base test class then but it's not that useful to add a base class if we currently only have a single class that would use it.

xano’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.53 KB

The TypedDataTest::createTypedData() $context parameter defaults to an array, but it is passed on as the $name parameter to TypedDataManager::create(), which should be a string. @fago confirmed this on IRC:

fago: Xano, it should be updated to match the typed data manager's create() parametrs

xano’s picture

StatusFileSize
new4.53 KB

Now with parameter name change.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Clean-up looks correct and seems to be blocking other tests. Back to RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great, faster tests++ :)

Committed and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.