air travel – Will the authority accept my second ticket as a confirmation that I am transiting

I booked two ticket from two different companies.

The first ticket is from Germany to Barcelona, arrives in the morning. The second is from Barcelona to non-Eu country departs at night.

Spain currently does not require any tests when going there for a transit. When they ask me for my corona test, will they accept my second ticket as a confirmation that I’m going there for less than 24h without going outside the airport?