public function testCRUD() { $this->_model->setData(['store_id' => 1, 'design' => 'Magento/blank', 'date_from' => date('Y-m-d', strtotime('-1 day')), 'date_to' => date('Y-m-d', strtotime('+1 day'))]); $this->_model->save(); $this->assertNotEmpty($this->_model->getId()); try { $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Theme\\Model\\Design'); $model->loadChange(1); $this->assertEquals($this->_model->getId(), $model->getId()); /* Design change that intersects with existing ones should not be saved, so exception is expected */ try { $model->setId(null); $model->save(); $this->fail('A validation failure is expected.'); } catch (\Magento\Framework\Exception\LocalizedException $e) { } $this->_model->delete(); } catch (\Exception $e) { $this->_model->delete(); throw $e; } $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Theme\\Model\\Design'); $model->loadChange(1); $this->assertEmpty($model->getId()); }