@@ 370-379 (lines=10) @@ | ||
367 | * |
|
368 | * @return void |
|
369 | */ |
|
370 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesPrioritySetting() |
|
371 | { |
|
372 | self::changeWorkingDirectory(); |
|
373 | ||
374 | $factory = new RuleSetFactory(); |
|
375 | $ruleSets = $factory->createRuleSets('refset3'); |
|
376 | ||
377 | $rule = $ruleSets[0]->getRules()->current(); |
|
378 | $this->assertSame(4, $rule->getPriority()); |
|
379 | } |
|
380 | ||
381 | /** |
|
382 | * testCreateRuleWithExpectedExample |
|
@@ 386-395 (lines=10) @@ | ||
383 | * |
|
384 | * @return void |
|
385 | */ |
|
386 | public function testCreateRuleWithExpectedExample() |
|
387 | { |
|
388 | self::changeWorkingDirectory(); |
|
389 | ||
390 | $factory = new RuleSetFactory(); |
|
391 | $ruleSets = $factory->createRuleSets('set1'); |
|
392 | ||
393 | $rule = $ruleSets[0]->getRules()->current(); |
|
394 | $this->assertEquals(array(__FUNCTION__), $rule->getExamples()); |
|
395 | } |
|
396 | ||
397 | /** |
|
398 | * testCreateRuleWithExpectedMultipleExamples |
|
@@ 418-427 (lines=10) @@ | ||
415 | * |
|
416 | * @return void |
|
417 | */ |
|
418 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesDescriptionSetting() |
|
419 | { |
|
420 | self::changeWorkingDirectory(); |
|
421 | ||
422 | $factory = new RuleSetFactory(); |
|
423 | $ruleSets = $factory->createRuleSets('refset3'); |
|
424 | ||
425 | $rule = $ruleSets[0]->getRules()->current(); |
|
426 | $this->assertSame('description 42', $rule->getDescription()); |
|
427 | } |
|
428 | ||
429 | /** |
|
430 | * testCreateRuleSetsWithRuleReferenceThatOverwritesPropertySetting |
|
@@ 434-443 (lines=10) @@ | ||
431 | * |
|
432 | * @return void |
|
433 | */ |
|
434 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesPropertySetting() |
|
435 | { |
|
436 | self::changeWorkingDirectory(); |
|
437 | ||
438 | $factory = new RuleSetFactory(); |
|
439 | $ruleSets = $factory->createRuleSets('refset3'); |
|
440 | ||
441 | $rule = $ruleSets[0]->getRules()->current(); |
|
442 | $this->assertSame(42, $rule->getIntProperty('foo')); |
|
443 | } |
|
444 | ||
445 | /** |
|
446 | * testFactorySupportsAlternativeSyntaxForPropertyValue |
|
@@ 450-459 (lines=10) @@ | ||
447 | * |
|
448 | * @return void |
|
449 | */ |
|
450 | public function testFactorySupportsAlternativeSyntaxForPropertyValue() |
|
451 | { |
|
452 | self::changeWorkingDirectory(); |
|
453 | ||
454 | $factory = new RuleSetFactory(); |
|
455 | $ruleSets = $factory->createRuleSets('alternative-property-value-syntax'); |
|
456 | ||
457 | $rule = $ruleSets[0]->getRules()->current(); |
|
458 | $this->assertSame(42, $rule->getIntProperty('foo')); |
|
459 | } |
|
460 | ||
461 | /** |
|
462 | * testCreateRuleSetsWithRuleReferenceThatOverwritesExamplesSetting |
|
@@ 466-477 (lines=12) @@ | ||
463 | * |
|
464 | * @return void |
|
465 | */ |
|
466 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesExamplesSetting() |
|
467 | { |
|
468 | self::changeWorkingDirectory(); |
|
469 | ||
470 | $factory = new RuleSetFactory(); |
|
471 | $ruleSets = $factory->createRuleSets('refset3'); |
|
472 | ||
473 | $rule = $ruleSets[0]->getRules()->current(); |
|
474 | ||
475 | $examples = $rule->getExamples(); |
|
476 | $this->assertEquals('foreach ($foo as $bar) { echo $bar; }', $examples[0]); |
|
477 | } |
|
478 | ||
479 | /** |
|
480 | * testCreateRuleSetsWithRuleReferenceThatOverwritesExamplesSetting |
|
@@ 484-493 (lines=10) @@ | ||
481 | * |
|
482 | * @return void |
|
483 | */ |
|
484 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesNameSetting() |
|
485 | { |
|
486 | self::changeWorkingDirectory(); |
|
487 | ||
488 | $factory = new RuleSetFactory(); |
|
489 | $ruleSets = $factory->createRuleSets('refset4'); |
|
490 | ||
491 | $rule = $ruleSets[0]->getRules()->current(); |
|
492 | $this->assertEquals('Name overwritten', $rule->getName()); |
|
493 | } |
|
494 | ||
495 | /** |
|
496 | * testCreateRuleSetsWithRuleReferenceThatOverwritesMessageSetting |
|
@@ 500-509 (lines=10) @@ | ||
497 | * |
|
498 | * @return void |
|
499 | */ |
|
500 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesMessageSetting() |
|
501 | { |
|
502 | self::changeWorkingDirectory(); |
|
503 | ||
504 | $factory = new RuleSetFactory(); |
|
505 | $ruleSets = $factory->createRuleSets('refset4'); |
|
506 | ||
507 | $rule = $ruleSets[0]->getRules()->current(); |
|
508 | $this->assertEquals('Message overwritten', $rule->getMessage()); |
|
509 | } |
|
510 | ||
511 | /** |
|
512 | * testCreateRuleSetsWithRuleReferenceThatOverwritesExtInfoUrlSetting |
|
@@ 516-525 (lines=10) @@ | ||
513 | * |
|
514 | * @return void |
|
515 | */ |
|
516 | public function testCreateRuleSetsWithRuleReferenceThatOverwritesExtInfoUrlSetting() |
|
517 | { |
|
518 | self::changeWorkingDirectory(); |
|
519 | ||
520 | $factory = new RuleSetFactory(); |
|
521 | $ruleSets = $factory->createRuleSets('refset4'); |
|
522 | ||
523 | $rule = $ruleSets[0]->getRules()->current(); |
|
524 | $this->assertEquals('http://example.com/overwritten', $rule->getExternalInfoUrl()); |
|
525 | } |
|
526 | ||
527 | /** |
|
528 | * testCreateRuleSetsWithRuleReferenceNotContainsExcludedRule |
|
@@ 532-541 (lines=10) @@ | ||
529 | * |
|
530 | * @return void |
|
531 | */ |
|
532 | public function testCreateRuleSetsWithRuleReferenceNotContainsExcludedRule() |
|
533 | { |
|
534 | self::changeWorkingDirectory(); |
|
535 | ||
536 | $factory = new RuleSetFactory(); |
|
537 | $ruleSets = $factory->createRuleSets('refset-exclude-one'); |
|
538 | ||
539 | $rules = $ruleSets[0]->getRules(); |
|
540 | $this->assertEquals(1, iterator_count($rules)); |
|
541 | } |
|
542 | ||
543 | /** |
|
544 | * testCreateRuleSetsWithRuleReferenceNotContainsExcludedRules |
|
@@ 548-557 (lines=10) @@ | ||
545 | * |
|
546 | * @return void |
|
547 | */ |
|
548 | public function testCreateRuleSetsWithRuleReferenceNotContainsExcludedRules() |
|
549 | { |
|
550 | self::changeWorkingDirectory(); |
|
551 | ||
552 | $factory = new RuleSetFactory(); |
|
553 | $ruleSets = $factory->createRuleSets('refset-exclude-all'); |
|
554 | ||
555 | $rules = $ruleSets[0]->getRules(); |
|
556 | $this->assertEquals(0, iterator_count($rules)); |
|
557 | } |
|
558 | ||
559 | /** |
|
560 | * Tests that the factory throws the expected exception for an invalid ruleset |