Elgg\Database\RelationshipsTest::testGetEntitiesFromRelationshipFilterByTimeCreatedUpper PHP Method

testGetEntitiesFromRelationshipFilterByTimeCreatedUpper() public method

Check that you can get entities by filtering them on relationship time created upper
    public function testGetEntitiesFromRelationshipFilterByTimeCreatedUpper()
    {
        // get a timestamp before creating the relationship
        $ts_lower = time() - 1;
        add_entity_relationship($this->guids[0], 'testGetEntitiesFromRelationship', $this->guids[1]);
        // get a timestamp after creating the relationship
        $ts_upper = time() + 1;
        // check that if ts_upper is after the relationship you get the just created entity
        $options = array('relationship' => 'testGetEntitiesFromRelationship', 'relationship_guid' => $this->guids[0], 'relationship_created_time_upper' => $ts_upper);
        $es = elgg_get_entities_from_relationship($options);
        $this->assertTrue(is_array($es));
        $this->assertIdentical(count($es), 1);
        foreach ($es as $e) {
            $this->assertEqual($this->guids[1], $e->guid);
        }
        // check that if ts_upper is before the relationship you get no entities
        $options = array('relationship' => 'testGetEntitiesFromRelationship', 'relationship_guid' => $this->guids[0], 'relationship_created_time_upper' => $ts_lower);
        $es = elgg_get_entities_from_relationship($options);
        $this->assertTrue(is_array($es));
        $this->assertIdentical(count($es), 0);
    }