Giter VIP home page Giter VIP logo

Comments (1)

roberto-butti avatar roberto-butti commented on July 29, 2024

Looking under the hood this is not an issue.
The element that determins the sorting of the relartions is the array of UUIDs .
In the dataset i created for testing stories-rleations.json the order is:
["997cfee2-cec3-4cad-9e06-7ef3d72f5b7d", "ba307a05-2b91-4ce8-ab24-bf328da1adb4", "c3a321a5-1163-4281-8643-2c79c13e22a3"]

so i created a specific test:

test('v2: check sorting for relations', function () {
    $client = new Client('test', null, $version = 'v2');
    // $client->editMode(false);
    $client->mockable([
        mockResponse('stories-relations', ['x-test' => 1], $version),
    ]);
    $client->resolveRelations('popular-articles.articles');
    $story = $client->getStoryBySlug('home')->getBody();
    $this->assertArrayHasKey('story', $story);
    $this->assertArrayHasKey('rels', $story);
    // With the dataset provided the right order should be
    // ["997cfee2-cec3-4cad-9e06-7ef3d72f5b7d", "ba307a05-2b91-4ce8-ab24-bf328da1adb4", "c3a321a5-1163-4281-8643-2c79c13e22a3"]
    $this->assertEquals(
        '997cfee2-cec3-4cad-9e06-7ef3d72f5b7d',
        $story['story']['content']['body'][1]['articles'][0]['uuid'],
        'checking the first relation'
    );
    $this->assertEquals(
        'ba307a05-2b91-4ce8-ab24-bf328da1adb4',
        $story['story']['content']['body'][1]['articles'][1]['uuid'],
        'checking the second relation'
    );
    $this->assertEquals(
        'c3a321a5-1163-4281-8643-2c79c13e22a3',
        $story['story']['content']['body'][1]['articles'][2]['uuid'],
        'checking the third relation'
    );

});

So i can close this issue.
I don't want to delete it to keep track in the history. If some developer has this kind of misunderstanding, the developer can find some explanation here (with the test I added in this comment).

from storyblok-php-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.