Opinion by
Judge Williams, Jr.,Gerald O. Hamm, Ph.D., appeals from an order of the Gonrt of Common Pleas of Philadelphia County dismissing his exceptions to the order granting appellees1 2compulsory nonsuit motion.
In accordance with the mandatory retirement provision of Section 1122 of the Public School Code (Code), 24 P..S. §11-1122,2 the Board of Education forcibly retired Ham.m, a high school teacher with more than twenty-five yeans experience in the Philadelphia school district, ,at the age of ¡sixty-six. Seeking reinstatement and challenging the constitutionality of Section 1122 under the ¡State and Federal Constitutions, Hamm filed ¡a Complaint in Mandamus in the common pleas court. After dismissal of the Board’s preliminary objections and motion for judgment on the pleadings, the matter proceeded to trial. Upon concluding, inter alia, that Hamm’s mandatory retirement, pursuant to Section 1122, violated neither equal protection nor due process guarantees of the Pennsylvania and United States constitutions, the trial court granted appellees’ motion for compulsory nonsuit. This appeal followed.
Although not addressed by the parties or the common pleas court, the threshold issue is whether mandamus is an appropriate action by which to challenge *549the constitutionality of Section 1122. Mandamus can compel the performance of a ministerial act or mandatory .du-ty only when there is a clear legal right in the plaintiff, a corresponding duty in .the defendant, and a want of any other appropriate and adequate remedy. Township of South Fayette v. Commonwealth of Pennsylvania, 73 Pa. Commonwealth Ct. 495, 506, 459 A.2d 41, 46 (1983).
The purpose of mandamus is not to establish legal rights, but to enforce those rights already established beyond peradventure. See Southerland v. Commonwealth, 36 D. & C.2d 786, 791 (1965). Through mandamus, Hamm, does not seek to force Board of Education compliance with the Code’s mandatory retirement provision. Instead, Hamm seeks to compel the Board of Education to disregard and contravene its clear duty under the Code by continuing to .employ him beyond the statutorily mandated retirement age. Using mandamus to compel .public officials to violate a clear statutory duty is not the proper .procedure for testing the constitutionality of a statute. Booz v. Reed, 398 Pa. 172, 157 A.2d 170 (1960); Burello v. State Employment Retirement System, 49 Pa. Commonwealth Ct. 364, 411 A.2d 852 (1980); see also, 18 Standard Pennsylvania Practice 2d §99:1.
Further, mandamus is inappropriate absent prior judicial invalidation o.r legislative repeal of the Code’s mandatory retirement provision, because Hamm’s right to continue teaching beyond the statutory retirement age is not clear. See Unger v. Township of Hampton, 437 Pa. 399, 263 A.2d 385 (1970) (where plaintiff’s right to building permit is contingent upon first invalidating zoning ordinance under which permit was denied, the right to the permit is not .sufficiently clear to constitute a basis for mandamus action). We are bound by our Supreme Court’s reasoning in Philadelphia Presbytery Homes, Inc. v. Abing*550ton Board of Commissioners, 440 Pa. 299, 303, 269 A.2d 871, 873 (1970):
[W]here it is necessary to establish the invalidity of an ordinance before the right sought to be vindicated by the plaintiff in mandamus can be said to exist, the right is not sufficiently “clear” to form the basis upon which to issue the writ.
Of equal importance is the rule that where other appropriate and adequate remedies exist an action in mandamus is not available. Township of South Fayette. In McIlvaine v. Pennsylvania State Police, 454 Pa. 129, 309 A.2d 801 (1973), appeal dismissed, 415 U.S. 986 (1974), declaratory judgment, and not mandamus, was held to be a proper action by which a retired State Police officer could constitutionally challenge a statutory, mandatory retirement policy. When Hamm instituted this mandamus action in 1977, he could have sought the aid of equity to compel his reinstatement or filed a declaratory judgment petition to challenge the constitutionality of Section 1122. Both constitute appropriate and adequate alternative remedies to mandamus.
Accordingly, we conclude that mandamus is wholly inappropriate here because (1) Hamm’s right to reach beyond the Code’s mandatory retirement age is not clear; (2) the Board of Education had a duty to terminate Hamm’s employment when he reached retirement-age; and, (3) other adequate and appropriate remedies (i.e., declaratory judgment or injunctive relief) are available. Since 'this mandamus action is completely inappropriate we are foreclosed from addressing the merits. See Mcllvaine (retired police officer’s use of improper remedy of mandamus to challenge constitutionality of mandatory retirement provision would, in normal circumstances, preclude treatment of merits).
*551For reasons different from those relied upon by the common pleas court, we affirm.
Order
And Now, this 17th day of January, 1984, the order of the Court of Common Pleas of Philadelphia County in the above-captioned matter is affirmed.
Board of Education for ¡the School District of Philadelphia and the Commonwealth of Pennsylvania.
Section 1122 of the Code, Act of March 10, 1949, P.L. 30, as amended, 24 P.S. §11-1122, provides pertinently :
[B]oards of school directors may terminate the service of any professional employe who has attained . . . the age of sixty-two except a professional employe who is a member of the old age and survivors insurance system. ... In such case the board may terminate the service of any such professional employe at the age of sixty-five or at the age at which the employe becomes eligible to receive full benefits under the Federal Social Security Act. (Footnotes omitted.)