public function OpignoCertificateTest::testCreate in Opigno certificate 8
Same name and namespace in other branches
- 3.x tests/src/Kernel/OpignoCertificateTest.php \Drupal\Tests\opigno_certificate\Kernel\OpignoCertificateTest::testCreate()
Tests Opigno certificate creation.
@covers ::preSave
File
- tests/
src/ Kernel/ OpignoCertificateTest.php, line 47
Class
- OpignoCertificateTest
- Tests the general behavior of opigno_certificate entities.
Namespace
Drupal\Tests\opigno_certificate\KernelCode
public function testCreate() {
// Check if default certificate was created properly.
/** @var \Drupal\opigno_certificate\Entity\OpignoCertificate $opigno_certificate */
$opigno_certificate = $this->entityTypeManager
->getStorage('opigno_certificate')
->create([
'bundle' => 'opigno_certificate',
'label' => $this
->randomString(),
]);
$this
->assertTrue($opigno_certificate, 'Default certificate was created successfully.');
$this
->assertEquals(SAVED_NEW, $opigno_certificate
->save(), 'Default certificate was saved successfully.');
// Check if template certificate was created properly.
/** @var \Drupal\opigno_certificate\Entity\OpignoCertificate $template_certificate */
$template_certificate = $this->entityTypeManager
->getStorage('opigno_certificate')
->create([
'bundle' => 'template',
'label' => $this
->randomString(),
]);
$this
->assertTrue($template_certificate, 'Template type certificate was created successfully.');
$this
->assertEquals(SAVED_NEW, $template_certificate
->save(), 'Template type certificate was saved successfully.');
}