create( \Magento\Cookie\Model\Config\Backend\Domain::class ); $domain->setValue($value); $domain->setPath('path'); try { $domain->save(); if ($exceptionMessage) { $this->fail('Failed to throw exception'); } else { $this->assertNotNull($domain->getId()); } } catch (LocalizedException $e) { $this->assertContains('Invalid domain name: ', $e->getMessage()); $this->assertEquals($exceptionMessage, $e->getMessage()); $this->assertNull($domain->getId()); } } /** * @return array */ public function beforeSaveDataProvider() { return [ 'not string' => [['array'], 'Invalid domain name: must be a string'], 'invalid hostname' => [ 'http://', 'Invalid domain name: The input does not match the expected structure for a DNS hostname; ' . 'The input does not appear to be a valid URI hostname; ' . 'The input does not appear to be a valid local network name', ], 'valid hostname' => ['hostname.com'], 'empty string' => [''], ]; } }