|
19 | 19 | * a) Number of conditions: multiple |
20 | 20 | * b) Logical Operators: AND, OR, NOT(AND), NOT(OR) |
21 | 21 | * c) Number of relations: single |
22 | | - * d) Columns: same |
| 22 | + * d) Columns: same, different |
23 | 23 | * e) Operators: same |
24 | 24 | * f) Comparisons: affirmation, negation |
25 | 25 | * e) Operators: different |
26 | | - * d) Columns: different |
27 | | - * e) Operators: same, different |
28 | 26 | * c) Number of relations: multiple |
29 | 27 | * e) Operators: same, different |
30 | 28 | * f) Comparisons: affirmation, negation |
@@ -652,12 +650,12 @@ public function testAndChainTargetingASingleRelationButDifferentColumnsWithDiffe |
652 | 650 | /** |
653 | 651 | * Search for offices where Donald works as accountant |
654 | 652 | * |
655 | | - * @equivalenceClass a:multiple, b:AND, c:single, d:different, e:same |
| 653 | + * @equivalenceClass a:multiple, b:AND, c:single, d:different, e:same, f:affirmation |
656 | 654 | * @dataProvider databases |
657 | 655 | * |
658 | 656 | * @param Connection $db |
659 | 657 | */ |
660 | | - public function testAndChainTargetingASingleRelationButDifferentColumnsWithTheSameOperator(Connection $db) |
| 658 | + public function testAndChainTargetingASingleRelationButDifferentColumnsWithTheSameAffirmativeOperator(Connection $db) |
661 | 659 | { |
662 | 660 | $this->createOfficesAndEmployees($db); |
663 | 661 |
|
@@ -689,6 +687,55 @@ public function testAndChainTargetingASingleRelationButDifferentColumnsWithTheSa |
689 | 687 | $this->assertSame(2, count($results), $sql); |
690 | 688 | } |
691 | 689 |
|
| 690 | + /** |
| 691 | + * Search for offices where Donald doesn't work as accountant |
| 692 | + * |
| 693 | + * @equivalenceClass a:multiple, b:AND, c:single, d:different, e:same, f:negation |
| 694 | + * @dataProvider databases |
| 695 | + * |
| 696 | + * @param Connection $db |
| 697 | + */ |
| 698 | + public function testAndChainTargetingASingleRelationButDifferentColumnsWithTheSameNegativeOperator(Connection $db) |
| 699 | + { |
| 700 | + $this->createOfficesAndEmployees($db); |
| 701 | + |
| 702 | + $offices = $db->prepexec( |
| 703 | + 'SELECT office.city FROM office' |
| 704 | + . ' WHERE office.id NOT IN (' |
| 705 | + . ' SELECT office.id FROM office' |
| 706 | + . ' LEFT JOIN employee e ON e.office_id = office.id' |
| 707 | + . ' WHERE e.name = ? AND e.role = ?' |
| 708 | + . ' GROUP BY office.id' |
| 709 | + . ' )' |
| 710 | + . ' ORDER BY office.id', |
| 711 | + ['Donald', 'Accountant'] |
| 712 | + )->fetchAll(); |
| 713 | + |
| 714 | + $this->assertSame('Amsterdam', $offices[0]['city'] ?? 'not found'); |
| 715 | + $this->assertSame('New York', $offices[1]['city'] ?? 'not found'); |
| 716 | + $this->assertSame('Cuxhaven', $offices[2]['city'] ?? 'not found'); |
| 717 | + $this->assertSame('Sydney', $offices[3]['city'] ?? 'not found'); |
| 718 | + $this->assertSame('Baghdad', $offices[4]['city'] ?? 'not found'); |
| 719 | + $this->assertSame(5, count($offices)); |
| 720 | + |
| 721 | + $offices = Office::on($db) |
| 722 | + ->columns(['office.city']) |
| 723 | + ->orderBy('office.id') |
| 724 | + ->filter(Filter::all( |
| 725 | + Filter::unequal('employee.name', 'Donald'), |
| 726 | + Filter::unequal('employee.role', 'Accountant') |
| 727 | + )); |
| 728 | + $results = iterator_to_array($offices); |
| 729 | + $sql = $this->getSql($offices); |
| 730 | + |
| 731 | + $this->assertSame('Amsterdam', $results[0]['city'] ?? 'not found', $sql); |
| 732 | + $this->assertSame('New York', $results[1]['city'] ?? 'not found', $sql); |
| 733 | + $this->assertSame('Cuxhaven', $results[2]['city'] ?? 'not found', $sql); |
| 734 | + $this->assertSame('Sydney', $results[3]['city'] ?? 'not found', $sql); |
| 735 | + $this->assertSame('Baghdad', $results[4]['city'] ?? 'not found', $sql); |
| 736 | + $this->assertSame(5, count($results), $sql); |
| 737 | + } |
| 738 | + |
692 | 739 | /** |
693 | 740 | * Search for offices where Donald works or someone else not as accountant |
694 | 741 | * |
@@ -742,12 +789,12 @@ public function testOrChainTargetingASingleRelationButDifferentColumnsWithDiffer |
742 | 789 | /** |
743 | 790 | * Search for offices where either Donald works or any other assistant |
744 | 791 | * |
745 | | - * @equivalenceClass a:multiple, b:OR, c:single, d:different, e:same |
| 792 | + * @equivalenceClass a:multiple, b:OR, c:single, d:different, e:same, f:affirmation |
746 | 793 | * @dataProvider databases |
747 | 794 | * |
748 | 795 | * @param Connection $db |
749 | 796 | */ |
750 | | - public function testOrChainTargetingASingleRelationButDifferentColumnsWithTheSameOperator(Connection $db) |
| 797 | + public function testOrChainTargetingASingleRelationButDifferentColumnsWithTheSameAffirmativeOperator(Connection $db) |
751 | 798 | { |
752 | 799 | $this->createOfficesAndEmployees($db); |
753 | 800 |
|
@@ -785,6 +832,58 @@ public function testOrChainTargetingASingleRelationButDifferentColumnsWithTheSam |
785 | 832 | $this->assertSame(5, count($results), $sql); |
786 | 833 | } |
787 | 834 |
|
| 835 | + /** |
| 836 | + * Search for offices where either Donald doesn't work or no-one as manager |
| 837 | + * |
| 838 | + * @equivalenceClass a:multiple, b:OR, c:single, d:different, e:same, f:negation |
| 839 | + * @dataProvider databases |
| 840 | + * |
| 841 | + * @param Connection $db |
| 842 | + */ |
| 843 | + public function testOrChainTargetingASingleRelationButDifferentColumnsWithTheSameNegativeOperator(Connection $db) |
| 844 | + { |
| 845 | + $this->createOfficesAndEmployees($db); |
| 846 | + |
| 847 | + $offices = $db->prepexec( |
| 848 | + 'SELECT office.city FROM office' |
| 849 | + . ' WHERE office.id NOT IN (' |
| 850 | + . ' SELECT office.id FROM office' |
| 851 | + . ' LEFT JOIN employee e ON e.office_id = office.id' |
| 852 | + . ' WHERE e.name = ?' |
| 853 | + . ' GROUP BY office.id' |
| 854 | + . ' ) OR office.id NOT IN (' |
| 855 | + . ' SELECT office.id FROM office' |
| 856 | + . ' LEFT JOIN employee e ON e.office_id = office.id' |
| 857 | + . ' WHERE e.role = ?' |
| 858 | + . ' GROUP BY office.id' |
| 859 | + . ' )' |
| 860 | + . ' ORDER BY office.id', |
| 861 | + ['Donald', 'Manager'] |
| 862 | + )->fetchAll(); |
| 863 | + |
| 864 | + $this->assertSame('Amsterdam', $offices[0]['city'] ?? 'not found'); |
| 865 | + $this->assertSame('New York', $offices[1]['city'] ?? 'not found'); |
| 866 | + $this->assertSame('Cuxhaven', $offices[2]['city'] ?? 'not found'); |
| 867 | + $this->assertSame('Sydney', $offices[3]['city'] ?? 'not found'); |
| 868 | + $this->assertSame(4, count($offices)); |
| 869 | + |
| 870 | + $offices = Office::on($db) |
| 871 | + ->columns(['office.city']) |
| 872 | + ->orderBy('office.id') |
| 873 | + ->filter(Filter::any( |
| 874 | + Filter::unequal('employee.name', 'Donald'), |
| 875 | + Filter::unequal('employee.role', 'Manager') |
| 876 | + )); |
| 877 | + $results = iterator_to_array($offices); |
| 878 | + $sql = $this->getSql($offices); |
| 879 | + |
| 880 | + $this->assertSame('Amsterdam', $results[0]['city'] ?? 'not found', $sql); |
| 881 | + $this->assertSame('New York', $results[1]['city'] ?? 'not found', $sql); |
| 882 | + $this->assertSame('Cuxhaven', $results[2]['city'] ?? 'not found', $sql); |
| 883 | + $this->assertSame('Sydney', $results[3]['city'] ?? 'not found', $sql); |
| 884 | + $this->assertSame(4, count($results), $sql); |
| 885 | + } |
| 886 | + |
788 | 887 | /** |
789 | 888 | * Search for offices where not just Huey works or only as a manager |
790 | 889 | * |
@@ -836,14 +935,15 @@ public function testNotChainTargetingASingleRelationButDifferentColumnsWithDiffe |
836 | 935 | /** |
837 | 936 | * Search for offices where not just Donald works or not as manager |
838 | 937 | * |
839 | | - * @equivalenceClass a:multiple, b:NOT(AND), c:single, d:different, e:same |
| 938 | + * @equivalenceClass a:multiple, b:NOT(AND), c:single, d:different, e:same, f:affirmation |
840 | 939 | * @dataProvider databases |
841 | 940 | * @todo Finds Cuxhaven instead of Baghdad. Not wrong, actually. Why does monitoring behave differently? |
842 | 941 | * |
843 | 942 | * @param Connection $db |
844 | 943 | */ |
845 | | - public function testNotChainTargetingASingleRelationButDifferentColumnsWithTheSameOperator(Connection $db) |
846 | | - { |
| 944 | + public function testNotChainTargetingASingleRelationButDifferentColumnsWithTheSameAffirmativeOperator( |
| 945 | + Connection $db |
| 946 | + ) { |
847 | 947 | $this->createOfficesAndEmployees($db); |
848 | 948 |
|
849 | 949 | $offices = $db->prepexec( |
@@ -882,6 +982,19 @@ public function testNotChainTargetingASingleRelationButDifferentColumnsWithTheSa |
882 | 982 | $this->assertSame(6, count($results), $sql); |
883 | 983 | } |
884 | 984 |
|
| 985 | + /** |
| 986 | + * Search for offices where ... |
| 987 | + * |
| 988 | + * @equivalenceClass a:multiple, b:NOT(AND), c:single, d:different, e:same, f:negation |
| 989 | + * @dataProvider databases |
| 990 | + * |
| 991 | + * @param Connection $db |
| 992 | + */ |
| 993 | + public function testNotChainTargetingASingleRelationButDifferentColumnsWithTheSameNegativeOperator(Connection $db) |
| 994 | + { |
| 995 | + $this->markTestIncomplete('This test has not been implemented yet.'); |
| 996 | + } |
| 997 | + |
885 | 998 | /** |
886 | 999 | * Search for offices where Donald works in the accounting department |
887 | 1000 | * |
|
0 commit comments