public function test_renderContent_returns_twig_parsed_content() { $campaign2 = Campaign::create(['name' => 'Test split2', 'file_name' => 'test-split2.htm', 'file_type' => 'partial', 'start_at' => Carbon::today(), 'end_at' => Carbon::tomorrow(), 'version_a_content' => 'Foo', 'version_b_content' => 'Bar']); $campaign1 = Campaign::create(['name' => 'Test split1', 'file_name' => 'test-split1.htm', 'file_type' => 'partial', 'start_at' => Carbon::today(), 'end_at' => Carbon::tomorrow(), 'version_a_content' => 'Hello {{ split(' . $campaign2->id . ') }}', 'version_b_content' => 'World {{ split(' . $campaign2->id . ') }}']); $content = CmsHelper::renderContent($campaign1->id); $this->assertTrue(in_array($content, ['Hello Foo', 'Hello Bar', 'World Foo', 'World Bar'])); }
/** * Hook into system events * * @return void */ public function boot() { // Extend the backend partial form Event::listen('backend.form.extendFieldsBefore', function ($form) { if ($form->model instanceof Partial) { CmsHelper::extendFormFields($form); } }); // Manage campaigns before a cms object is saved Event::listen('cms.template.processSettingsBeforeSave', function ($controller) { if ($data = input('splitter')) { CmsHelper::beforeSave($controller, input('splitter')); } }); }