RateWidgetCrudTest.php in Rate 8.2
File
tests/src/Functional/RateWidgetCrudTest.php
View source
<?php
namespace Drupal\Tests\rate\Functional;
class RateWidgetCrudTest extends RateWidgetTestBase {
public function testCrudEntityType() {
$options = [];
$entity_types = [
'node.article',
];
$comment_types = [];
$voting = [
'use_deadline' => 0,
];
$display = [];
$results = [];
$created_rate_widget = $this
->createRateWidget('dummy_rate_widget', 'Dummy rate widget', 'fivestar', $options, $entity_types, $comment_types, $voting, $display, $results);
drupal_static_reset();
$rate_widget = $this
->loadRateWidget('dummy_rate_widget');
$values = [
'Label' => 'Label',
'Options' => 'Options',
];
foreach ($values as $key => $label) {
$this
->assertEquals(call_user_func([
$rate_widget,
'get' . $key,
]), call_user_func([
$created_rate_widget,
'get' . $key,
]), 'The ' . $label . ' between the rate widget we created and loaded were not the same');
}
$rate_widget
->setLabel('New label');
$rate_widget
->save();
drupal_static_reset();
$rate_widget = $this
->loadRateWidget('dummy_rate_widget');
$this
->assertEqual($rate_widget
->getLabel(), 'New label', 'The rate widget was updated successfully');
$rate_widget
->delete();
drupal_static_reset();
$this
->assertNull($this
->loadRateWidget('dummy_rate_widget'), 'The rate widget was not found in the DB');
}
}