/** * tests the functionality related to the init code */ public function testInitCode() { LivePubHelper::$vars = array(); LivePubHelper::init_pub(); // after this is called, there should be one entry - the base_init_code LivePubHelper::clear_init_code(); $this->assertEquals(count(LivePubHelper::$init_code), 1); $this->assertEquals(LivePubHelper::get_init_code(), LivePubHelper::$base_init_code . "\n"); // try a few things to make sure the php tags are added appropriately LivePubHelper::$init_code = array('test'); $this->assertEquals("<?php test ?>\n", LivePubHelper::get_init_code()); LivePubHelper::$init_code = array('<?php test'); $this->assertEquals("<?php test ?>\n", LivePubHelper::get_init_code()); LivePubHelper::$init_code = array('test ?>'); $this->assertEquals("<?php test ?>\n", LivePubHelper::get_init_code()); LivePubHelper::$init_code = array('<?php test ?>'); $this->assertEquals("<?php test ?>\n", LivePubHelper::get_init_code()); LivePubHelper::$init_code = array(); $this->assertEquals("", LivePubHelper::get_init_code()); // test variables LivePubHelper::$vars = array('a' => "'b'", 'b' => true, 'c' => "4"); $this->assertEquals("\n<?php\n\$a = 'b';\n\$c = 4;\n\n?>\n", LivePubHelper::get_init_code()); LivePubHelper::stop_pub(); }