public function AcquiaLiftWebTestFundamentals::testMachineNameValidation in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 tests/acquia_lift.test \AcquiaLiftWebTestFundamentals::testMachineNameValidation()
Tests that new agents on the site cannot override existing agents in Lift.
File
- tests/
acquia_lift.test, line 761 - Integration tests for Acquia Lift module.
Class
Code
public function testMachineNameValidation() {
$agent = new stdClass();
$agent->title = 'my-existing-agent';
$agent->id = 'my-existing-agent';
$agent->algorithm = 'bernoulli';
$agent->created = "4605-05-17T10:47:17.530Z";
$agent->decisions_sets = array();
$agent->goals = array();
$test_data = array(
'campaigns' => array(
$agent,
),
);
variable_set('acquia_lift_web_test_data', $test_data);
AcquiaLiftAPI::setTestInstance();
// Try to create a new agent with the same name as one that exists in Lift.
$this
->createTestAgent('my-existing-agent', array(
'control_rate' => 10,
'explore_rate' => 30,
), self::$agent_plugin);
$this
->resetAll();
$agent = personalize_agent_load_agent('my-existing-agent');
$this
->assertNull($agent);
$agent = personalize_agent_load_agent('my-existing-agent-0');
$this
->assertTrue($agent instanceof AcquiaLiftLearningAgentInterface);
}