/** * 初始化一个meta管理类 * @param MetaManager $meta_param * @return inited MetaManager on success or false on failure */ private static function _init_meta($meta_param) { $meta = new BigpipeMetaManager(); if (false === $meta->init($meta_param)) { return false; } return $meta; }
public function testDeleteEntry() { $subject = new BigpipeMetaManager(); // 测试1:未init时调用接口 $path = '/path'; $this->assertFalse($subject->delete_entry($path)); $this->assertTrue(TestUtilities::set_private_var($subject, '_inited', true)); // 定义zk行为 $this->stub_zk->expects($this->any())->method('exists')->will($this->onConsecutiveCalls(false, true)); $this->stub_zk->expects($this->once())->method('remove_path')->will($this->returnValue(true)); $this->assertTrue(TestUtilities::set_private_var($subject, '_zk_connection', $this->stub_zk)); // 测试2:set的etnry不存在 $this->assertFalse($subject->delete_entry($path)); // 测试5:成功set $this->assertTrue($subject->delete_entry($path)); }