Пример #1
0
    public function testGetDelayedWithCallbackAndSelectInfo()
    {
        $items = array(
            'key1' => 'value1',
            'key2' => 'value2',
            'key3' => 'value3'
        );

        $this->assertSame(array(), $this->_storage->setItems($items));

        $fetchedItems = array();
        $capabilities = $this->_storage->getCapabilities();
        $this->assertTrue($this->_storage->getDelayed(array_keys($items), array(
            'callback' => function($item) use (&$fetchedItems) {
                $fetchedItems[] = $item;
            },
            'select' => $capabilities->getSupportedMetadata()
        )));

        // wait for callback
        sleep(1);

        $this->assertEquals(count($items), count($fetchedItems));
        foreach ($fetchedItems as $item) {
            foreach ($capabilities->getSupportedMetadata() as $selectProperty) {
                $this->assertArrayHasKey($selectProperty, $item);
            }
        }
    }