public function FractionGenerateSampleValueTest::testGenerateSampleValue in Fraction 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/FractionGenerateSampleValueTest.php \Drupal\Tests\fraction\Kernel\FractionGenerateSampleValueTest::testGenerateSampleValue()
Tests setting the sample value.
File
- tests/
src/ Kernel/ FractionGenerateSampleValueTest.php, line 58
Class
- FractionGenerateSampleValueTest
- Class to test generating and setting sample values.
Namespace
Drupal\Tests\fraction\KernelCode
public function testGenerateSampleValue() {
$node = Node::create([
'type' => 'article',
'title' => 'test',
]);
$node
->save();
$node
->get(self::FIELD_NAME)
->generateSampleItems();
$this
->entityValidateAndSave($node);
$result = $node
->get(self::FIELD_NAME)
->getValue();
$result = reset($result);
$this
->assertTrue(is_array($result));
$this
->assertArrayHasKey('numerator', $result);
$this
->assertArrayHasKey('denominator', $result);
$this
->assertTrue($result['denominator'] > 0, TRUE);
}