In the Quran, Muhammad relays the story of Saul and David fighting the Philistines, and David killing Goliath:
Surah 2:249-251
249 When Saul marched forth with his army, he cautioned: “Allah will test you with a river. So whoever drinks ˹his fill˺ from it is not with me, and whoever does not taste it - except a sip from the hollow of his hands - is definitely with me.” They all drank ˹their fill˺ except for a few! When he and the ˹remaining˺ faithful with him crossed the river, they said, “Now we are no match for Goliath and his warriors.” But those ˹believers˺ who were certain they would meet Allah reasoned, “How many times has a small force vanquished a mighty army by the Will of Allah! And Allah is ˹always˺ with the steadfast.”
250 When they advanced to face Goliath and his warriors, they prayed, “Our Lord! Shower us with perseverance, make our steps firm, and give us victory over the disbelieving people.”
251 So they defeated them by Allah’s Will, and David killed Goliath. And Allah blessed David with kingship and wisdom and taught him what He willed. Had Allah not repelled a group of people by ˹the might of˺ another, corruption would have dominated the earth, but Allah is Gracious to all.
Above, in verse 249, Muhammad tells a story that is absolutely nowhere to be found in the Biblical account of Saul and David fighting the Philistines, and David killing Goliath. In the Bible, their fight against Goliath and the Philistines takes place in 1 Samuel 17, and never in that chapter, nor the whole of the book of 1 Samuel, does any such river-trial event take place.
However, those familiar with the Bible will recognize that the exact event described in verse 249 does take place in Scripture, but it's found in the book of Judges, around 200 years before David and Saul are fighting against the Philistines:
Judges 7:1-7
1 Then Jerubbaal, who is Gideon, and all the people that were with him, rose up early, and pitched beside the well of Harod: so that the host of the Midianites were on the north side of them, by the hill of Moreh, in the valley.
2 And the LORD said unto Gideon, The people that are with thee are too many for me to give the Midianites into their hands, lest Israel vaunt themselves against me, saying, Mine own hand hath saved me.
3 Now therefore go to, proclaim in the ears of the people, saying, Whosoever is fearful and afraid, let him return and depart early from mount Gilead. And there returned of the people twenty and two thousand; and there remained ten thousand.
4 And the LORD said unto Gideon, The people are yet too many; bring them down unto the water, and I will try them for thee there: and it shall be, that of whom I say unto thee, This shall go with thee, the same shall go with thee; and of whomsoever I say unto thee, This shall not go with thee, the same shall not go.
5 So he brought down the people unto the water: and the LORD said unto Gideon, Every one that lappeth of the water with his tongue, as a dog lappeth, him shalt thou set by himself; likewise every one that boweth down upon his knees to drink.
6 And the number of them that lapped, putting their hand to their mouth, were three hundred men: but all the rest of the people bowed down upon their knees to drink water.
7 And the LORD said unto Gideon, By the three hundred men that lapped will I save you, and deliver the Midianites into thine hand: and let all the other people go every man unto his place.
Above, we see that the Lord is thinning out Gideon's army, so that they recognize that they are victorious not through their own power, but through the Lord's help. And, the Lord uses how they drink water as the filter by which Gideon is to know who should be kept - exactly as was seen in Surah 2:249.
Take a moment also to notice how terribly the story is butchered in Surah 2. It has Saul telling his men what the test is, prior to them actually performing the test, which makes no sense. The Biblical account has the Lord tell Gideon the test, and then Gideon observes to see what his men do. That makes sense. Muhammad gets everything wrong, and turns it into a childish, nonsensical story, lacking context, conflating characters and events, and attempting to crunch an entire story into a few sentences.
Muhammad tried to recount a Bible story, but conflated two distinct stories, which took place around 200 years apart. This is similar to how he conflated Mary, the mother of Jesus, and Miriam, the sister of Moses, as covered in this article.
These are mistakes which demonstrate that he had, at best, an oral familiarity with the Bible, and so he gets the chronology incredibly wrong, combining characters and events that were, in reality, separated by hundreds of years.