Philosopher's Stone has quite a few direct correspondences. The letter/golden ticket, the factory/Hogwarts (I could go on, but it would require me to reread it, not that that would be a bad thing). The unjustly discriminated against kid is another Dahl trope (although not one in CF per se). And more generally, the style is very similar. Beyond the first book it diverges, however.
Copyright considers things a unique work if less than something like 10% is copied. Harry Potter is in no danger. Even changing the golden ticket to a letter is enough to get around infringement there.
Of course consult a lawyer if the 10% figure above it important to your copy - there are lots of details that I don't know.
I only felt the need to establish enough similarity to demonstrate that the joke was funny, not so much the Dahl estate could take Rowling's hard-earned money. :)