public function testOutputArray() { $obj = new TestContainer(); $this->cacheMock->shouldReceive('set')->once()->with('key1', $obj->arrayCallable()); $ref = $this->obj; $result = $ref(array($obj, 'arrayCallable'), 'key1')->toJSON(); $this->assertEquals('[{"foo":"bar"},{"foo2":"bar2"}]', $result); $obj = ''; }
public function testGetTypeReturnsNull() { $container = new TestContainer(); $this->assertNull($container->getType()); }
$c->set('foo', 'foo_value'); $c->set('bar', 'bar_value'); $c->clear(); /* Test custom getters and setters */ class TestContainer extends Container { function get_foo() { return 'foo_value'; } function get_baz($param = 'default') { return 'baz_value_' . $param; } } $test = new TestContainer(); $test->set('bar', 'bar_value'); /* Test keys() */ $keys = $test->keys(); assert('array_has_value($keys, "bar") === true'); assert('array_has_value($keys, "foo") === true'); assert('array_has_value($keys, "baz") === true'); $keys = $test->_keys(); assert('array_has_value($keys, "bar") === true'); assert('array_has_value($keys, "foo") === false'); assert('array_has_value($keys, "baz") === false'); /* Test to_array() */ $test->set('foo', 'bla'); $data = $test->to_array(true); assert('$data["foo"] === "foo_value"'); assert('$data["foo"] !== "wrong"');