lithium\test\filter\Affected::apply PHP Method

apply() public static method

Takes an instance of an object (usually a Collection object) containing test instances. Adds affected tests to the test collection.
public static apply ( object $report, array $tests, array $options = [] ) : object
$report object Instance of Report which is calling apply.
$tests array The test to apply this filter on
$options array Not used.
return object Returns the instance of `$tests`.
    public static function apply($report, $tests, array $options = array())
    {
        $affected = array();
        $testsClasses = $tests->map('get_class', array('collect' => false));
        foreach ($tests as $test) {
            $affected = array_merge($affected, self::_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__, array($class => $test));
        }
        return $tests;
    }

Usage Example

Example #1
0
 public function testCyclicDependency()
 {
     $group = new Group();
     $group->add('lithium\\tests\\cases\\g11n\\CatalogTest');
     $group->add('lithium\\tests\\cases\\g11n\\MessageTest');
     $this->report->group = $group;
     $tests = Affected::apply($this->report, $group->tests());
     $expected = array('lithium\\tests\\cases\\g11n\\CatalogTest', 'lithium\\tests\\cases\\g11n\\MessageTest', 'lithium\\tests\\cases\\console\\command\\g11n\\ExtractTest');
     $result = $tests->map('get_class', array('collect' => false));
     $this->assertEqual($expected, $result);
 }
All Usage Examples Of lithium\test\filter\Affected::apply