lithium\test\filter\Affected::apply()

public static method

Takes an instance of an object (usually a Collection object) containing test instances. Adds affected tests to the test collection.

Parameters

  • object $report

    Instance of Report which is calling apply.

  • \lithium\util\Collection $tests

    The tests to apply this filter on.

  • array $options

    Not used.

Returns

object

Returns the instance of $tests.

Source

	public static function apply($report, $tests, array $options = []) {
		$affected = [];
		$testsClasses = $tests->map('get_class', ['collect' => false]);

		foreach ($tests as $test) {
			$affected = array_merge($affected, static::_affected($test->subject()));
		}
		$affected = array_unique($affected);

		foreach ($affected as $class) {
			$test = Unit::get($class);

			if ($test && !in_array($test, $testsClasses)) {
				$tests[] = new $test();
			}
			$report->collect(__CLASS__, [$class => $test]);
		}
		return $tests;
	}