diff --git a/tests/src/Unit/EntitySerializationTest.php b/tests/src/Kernel/EntitySerializationTest.php
similarity index 55%
rename from tests/src/Unit/EntitySerializationTest.php
rename to tests/src/Kernel/EntitySerializationTest.php
index cab8598..10d588a 100644
--- a/tests/src/Unit/EntitySerializationTest.php
+++ b/tests/src/Kernel/EntitySerializationTest.php
@@ -1,33 +1,29 @@
 <?php
 
-namespace Drupal\Tests\search_api\Unit;
+namespace Drupal\Tests\search_api\Kernel;
 
 use Drupal\Component\Serialization\Yaml;
-use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\KernelTests\KernelTestBase;
 use Drupal\search_api\Entity\Index;
 use Drupal\search_api\Entity\Server;
-use Drupal\Tests\UnitTestCase;
 
 /**
  * Tests the serialization of the entities.
  *
  * @group search_api
  */
-class EntitySerializationTest extends UnitTestCase {
+class EntitySerializationTest extends KernelTestBase {
 
   /**
    * {@inheritdoc}
    */
-  public function setUp() {
-    $config = $this->getMockBuilder('Drupal\Core\Config\Config')
-      ->disableOriginalConstructor()
-      ->getMock();
-    $mock_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
-    $mock_factory->method('get')->willReturn($config);
-    $container = new ContainerBuilder();
-    $container->set('config.factory', $mock_factory);
-    \Drupal::setContainer($container);
-  }
+  public static $modules = array(
+    'search_api',
+    'search_api_test',
+    'node',
+    'user',
+    'system',
+  );
 
   /**
    * Tests that serialization of index entities doesn't lead to data loss.
@@ -38,10 +34,26 @@ public function testIndexSerialization() {
     $index_values = Yaml::decode(file_get_contents($path));
     $index = new Index($index_values, 'search_api_index');
 
+    // Make some changes to the index to ensure they're saved, too.
+    $field_helper = \Drupal::getContainer()->get('search_api.fields_helper');
+    $field_info = array(
+      'type' => 'date',
+      'datasource_id' => 'entity:node',
+      'property_path' => 'uid:entity:created',
+    );
+    $index->addField($field_helper->createField($index, 'test1', $field_info));
+    $index->addDatasource($index->createPlugin('datasource', 'entity:user'));
+    $index->addProcessor($index->createPlugin('processor', 'highlight'));
+    $index->setTracker($index->createPlugin('tracker', 'search_api_test'));
+
+    /** @var \Drupal\search_api\IndexInterface $serialized */
     $serialized = unserialize(serialize($index));
 
     $this->assertNotEmpty($serialized);
-    $this->assertEquals($index, $serialized);
+    $storage = \Drupal::entityTypeManager()->getStorage('search_api_index');
+    $index->preSave($storage);
+    $serialized->preSave($storage);
+    $this->assertEquals($index->toArray(), $serialized->toArray());
   }
 
   /**
