BRIDGEPORT, Conn. (CBSNewYork/AP) — A New Haven man charged with sexually molesting a 13-year-old boy in the bathroom of a Bridgeport church has pleaded guilty just before his trial was about to start.

Gary Robinson, 32, agreed to plead guilty Tuesday to risk of injury to a minor, the Connecticut Post reported.

READ MORE: New York Weather: CBS2's 10/27 Wednesday Afternoon Forecast

Robinson faces up to four years in prison at sentencing scheduled for July 1, but the judge said Robinson’s lawyer could ask for a shorter term.

Prosecutors say the boy’s parents are not happy with the plea but have agreed to go along with it to spare their son from testifying.

READ MORE: Long Island's South Shore Under High Wind Warning As Nor'easter Wraps Up

Tavone Brown, 36, of Bridgeport and Ryan Covington, 26, of Stratford, are also facing charges after being accused of sending explicit text messages and photographs to the child, the Post reported.

The assault occurred at the Prayer Tabernacle Church of Love in 2012.

MORE NEWS: Health Care Workers Back In Court To Battle New York State Vaccine Mandate

(TM and © Copyright 2016 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2016 CBS Broadcasting Inc. Used under license. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)