STANFORD — The toughest test of the year for Stanford’s defense just got a whole lot tougher.

Fifth-year senior defensive end and co-captain Ben Gardner is out for the season with a left pectoral injury, handing the sixth-ranked Cardinal (7-1, 5-1, Pac-12) a major blow before facing No. 2 Oregon (8-0, 5-0) on Nov. 7. Stanford coach David Shaw said Gardner will undergo surgery to repair the damaged muscle.

Shaw said “there’s a chance” that fellow starting defensive end Henry Anderson could return against the Ducks but he will make the final decision after Anderson practices this weekend, which both teams have off. Anderson has missed the last six games since he hurt his knee in a victory against Army on Sept. 14.

The timing of Gardner’s injury could not be worse for Stanford’s defense. Oregon is averaging 632.1 yards and 55.6 points per game. Both rank second in the nation behind Baylor.

“If we’re not fully manned, it’s ridiculously difficult,” Shaw said.

Gardner hurt his left arm in Stanford’s win over Washington on Oct. 5. He had played through pain — saying last week that, at times, his arm “shuts down” — until a collision in the third quarter of Stanford’s 20-12 victory at Oregon State last Saturday sidelined him for good. Shaw said the injuries are unrelated.

Gardner, who made most of the defensive line adjustments, ends his collegiate career with 17 1/2 sacks and 34 tackles. He is hoping to land in the NFL, where he could be a possible late-round pick.

“While this is not the way I had imagined my college playing days ending, all I can do is look up and thank God for one heck of a ride,” Gardner wrote in a statement released by the school. He also encouraged his teammates to “beat Oregon and keep this thing rolling.”

Injuries and location aside, the matchup at Stanford Stadium next week sets up similarly to the one in Eugene a year ago.

Last season, the Cardinal toppled top-ranked Oregon 17-14 in overtime en route to a conference title and the school’s first Rose Bowl victory in 41 years. In the first 10 games before that contest, the Ducks looked unstoppable, leading the Football Bowl Subdivision with 54.8 points per game and never scoring fewer than 42 points. Oregon averaged 325 yards rushing before the Cardinal held them to 198.

“Defensively, it was one of those performances I’ll never forget,” linebacker A.J. Tarpley said. “The No. 1 thing was tackling. With those guys, if one guy is out of their lane or not doing their job, even if you are there and you miss a tackle, they have the elite athletes to score a touchdown from anywhere on the field.”

The Cardinal defense has still been dominant, at times, despite the recent rash of injuries. In the past two weeks alone, Stanford has shut down UCLA (10 points) and Oregon State (12 points) in victories.

Oregon, led by Heisman Trophy hopeful Marcus Mariota at quarterback, presents all kinds of other challenges — notably more speed and misdirection. If Anderson can’t play, Shaw said former tight end Luke Kaumatule, linemen Anthony Hayes and Aziz Shittu, and outside linebacker Blake Lueders will be counted on to fill the gap.

“We know we have a big task at hand playing them a little banged up,” said Josh Mauro, who has been starting in Anderson’s place. “(Defensive line) Coach (Randy) Hart likes to say, ‘There really is no limit of plays you can play. There’s just one more. You got one more in the tank for the next play.’ So however many plays everybody needs to play, we’re just going to go as hard as we can.”

Stanford, which ended Oregon’s run of three straight conference titles last season, is far more familiar with facing the Quack Attack than in the past.

Stanford dedicates at least one hour of practice every week to defending spread offenses, which started after losing 53-30 and 52-31 to Oregon in 2011 and 2010, respectively. The preparation includes two offenses — one running a play, the other ready to go to the line of scrimmage immediately after it’s over — going against the defense for when teams such as Oregon try to line up quickly.

Practicing for Oregon’s up-tempo pace is also not as difficult it used to be, Shaw said, because so many other teams in the Pac-12 run a similar style.

“It helps a lot that it’s not just Oregon week when we do it,” Shaw said. “We do it pretty much year round.”

———

NOTES: Stanford WR Devon Cajuste (right knee) will try to practice this week but remains questionable for Oregon, Shaw said. Cajuste sat out against Oregon State last week. ... K Jordan Williamson, who has missed the past two games, also will practice this week. Shaw is hopeful Williamson, who kicked the winning 37-yard field goal in overtime in Eugene last year, will be able to return against the Ducks. ... Shaw is giving his team Thursday and Friday off before a short practice Saturday.