If you see that you start to get code-duplication within the test-case you can start to refactor the code of the test-case as well.
However, take care that you do a refactoring only when all tests are green (pass). This rule does not only apply to the code-base but also to the test-base.
For example, you can move duplicate code into a private method that you then call in the public testXyz()-Method.
Here is an example given of a private helper function in a test-case, the scenario is different, but it should help to illustrate, from the answer to "PHPUnit Testing version of assertIsA":
private function assertNumber($actual, $message = "Is a number") { $isScalar = is_scalar($actual); $isNumber = $isScalar && (is_int($actual) || is_float($actual)); $this->assertTrue($isNumber, $message); }
Another way to make a re-usable test is with a data-provider, however that is more for test-data. If for example multiple test methods require the same test-data both can share one data-provider.
Hope this helps for some general guidance. Try out yourself and don't forget to put all your code and tests under version control and you commit often.