<?php

declare(strict_types=1);

it('checks PSR HTTP message interfaces before trusting a Composer vendor tree', function (): void {
    $entrypointPath = '/usr/local/bin/docker-entrypoint.sh';
    if (!is_file($entrypointPath)) {
        $this->markTestSkipped('Docker entrypoint is only available inside the PHP container.');
    }

    $entrypoint = (string)file_get_contents($entrypointPath);

    expect($entrypoint)->toContain('http_message_sanity_ok')
        ->and($entrypoint)->toContain('composer_lock_has_package "$dir" "psr/http-message"')
        ->and($entrypoint)->toContain('UriInterface.php')
        ->and($entrypoint)->toContain('StreamInterface.php')
        ->and($entrypoint)->toContain('interface_exists("Psr\\\\Http\\\\Message\\\\UriInterface")')
        ->and($entrypoint)->toContain('interface_exists("Psr\\\\Http\\\\Message\\\\StreamInterface")')
        ->and($entrypoint)->toContain('if ! http_message_sanity_ok "$dir"; then');
});
