File tree Expand file tree Collapse file tree 11 files changed +136
-21
lines changed
Expand file tree Collapse file tree 11 files changed +136
-21
lines changed Original file line number Diff line number Diff line change 1+ .idea /
12files /
23repo /
34vendor /
Original file line number Diff line number Diff line change @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. This projec
44
55## [ unreleased] Unreleased
66
7+
8+ ## [ 1.1.7] 2024-06-05
9+
10+ * Fix - ` Collection::get_by_group() ` now properly works with a single string group name.
11+ * Fix - ` Group_FilterIterator::count() ` now properly returns the filtered count and not the base iterator count.
12+ * Fix - ` Needs_Update_FilterIterator::count() ` now properly returns the filtered count and not the base iterator count.
13+ * Fix - Use proper PSR namespacing for tests.
14+ * Tests - code clean up and file name standardization.
15+
16+ ## [ 1.1.3] 2023-04-04
17+
718* Feature - Added ` Table::has_foreign_key() ` method.
819
920## [ 1.1.2] 2022-11-2
Original file line number Diff line number Diff line change 3939 },
4040 "autoload-dev" : {
4141 "psr-4" : {
42- "StellarWP\\ Schema\\ Tests\\ " : " tests/_support/Helper/" ,
42+ "StellarWP\\ Schema\\ Tests\\ " : [
43+ " tests/_support/Helper/" ,
44+ " tests/wpunit/"
45+ ],
4346 "StellarWP\\ Schema\\ Tests\\ Traits\\ " : " tests/_support/Traits/"
4447 }
4548 },
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ public function get( string $key ): Schema_Interface {
7575 * @return Filters\Group_FilterIterator
7676 */
7777 public function get_by_group ( $ groups , $ iterator = null ): Filters \Group_FilterIterator {
78- return new Filters \Group_FilterIterator ( $ groups , $ iterator ?: $ this );
78+ return new Filters \Group_FilterIterator ( ( array ) $ groups , $ iterator ?: $ this );
7979 }
8080
8181 /**
Original file line number Diff line number Diff line change 22
33namespace StellarWP \Schema \Tables \Filters ;
44
5- class Group_FilterIterator extends \FilterIterator implements \Countable {
5+ use CallbackFilterIterator ;
6+ use Countable ;
7+ use FilterIterator ;
8+ use Iterator ;
9+
10+ class Group_FilterIterator extends FilterIterator implements Countable {
11+
612 /**
713 * Groups to filter.
814 *
915 * @since 1.0.0
1016 *
1117 * @var array<string>
1218 */
13- private $ groups = [] ;
19+ private $ groups ;
1420
1521 /**
1622 * Constructor.
1723 *
1824 * @since 1.0.0
1925 *
2026 * @param array<string> $groups Paths to filter.
21- * @param \ Iterator $iterator Iterator to filter.
27+ * @param Iterator $iterator Iterator to filter.
2228 */
23- public function __construct ( array $ groups , \ Iterator $ iterator ) {
29+ public function __construct ( array $ groups , Iterator $ iterator ) {
2430 parent ::__construct ( $ iterator );
2531
26- $ this ->groups = ( array ) $ groups ;
32+ $ this ->groups = $ groups ;
2733 }
2834
2935 /**
@@ -39,6 +45,8 @@ public function accept(): bool {
3945 * @inheritDoc
4046 */
4147 public function count (): int {
42- return iterator_count ( $ this ->getInnerIterator () );
48+ return iterator_count ( new CallbackFilterIterator ( $ this ->getInnerIterator (), function (): bool {
49+ return $ this ->accept ();
50+ } ) );
4351 }
4452}
Original file line number Diff line number Diff line change 22
33namespace StellarWP \Schema \Tables \Filters ;
44
5- class Needs_Update_FilterIterator extends \FilterIterator implements \Countable {
5+ use CallbackFilterIterator ;
6+ use Countable ;
7+ use FilterIterator ;
8+
9+ class Needs_Update_FilterIterator extends FilterIterator implements Countable {
610 /**
711 * @inheritDoc
812 */
@@ -16,6 +20,8 @@ public function accept(): bool {
1620 * @inheritDoc
1721 */
1822 public function count (): int {
19- return iterator_count ( $ this ->getInnerIterator () );
23+ return iterator_count ( new CallbackFilterIterator ( $ this ->getInnerIterator (), function (): bool {
24+ return $ this ->accept ();
25+ } ) );
2026 }
2127}
Original file line number Diff line number Diff line change 22
33namespace StellarWP \Schema \Tests ;
44
5- use lucatume \DI52 \App ;
6- use StellarWP \Schema \Tests \Container ;
5+ use Codeception \Test \Unit ;
76use StellarWP \Schema \Config ;
87use StellarWP \DB \DB ;
98use StellarWP \Schema \Schema ;
109
11- class SchemaTestCase extends \ Codeception \ Test \ Unit {
10+ class SchemaTestCase extends Unit {
1211 protected $ backupGlobals = false ;
1312
14- public function setUp () {
13+ protected function setUp () {
1514 // before
1615 parent ::setUp ();
1716
Original file line number Diff line number Diff line change 44
55use StellarWP \Schema \Activation ;
66use StellarWP \Schema \Builder ;
7+ use StellarWP \Schema \Config ;
78use StellarWP \Schema \Fields \Contracts \Field ;
89use StellarWP \Schema \Tables \Contracts \Table ;
910
@@ -109,6 +110,36 @@ protected function get_definition() {
109110 return $ table ;
110111 }
111112
113+ /**
114+ * Get a fake table to verify its creation.
115+ */
116+ public function get_simple_table_alt_group (): Table {
117+ return new class extends Table {
118+ const SCHEMA_VERSION = '1.0.0 ' ;
119+
120+ protected static $ base_table_name = 'simple-alt ' ;
121+ protected static $ group = 'test ' ;
122+ protected static $ schema_slug = 'bork-simple-alt ' ;
123+ protected static $ uid_column = 'id ' ;
124+
125+ protected function get_definition (): string {
126+ global $ wpdb ;
127+ $ table_name = self ::table_name ();
128+ $ charset_collate = $ wpdb ->get_charset_collate ();
129+
130+ return "
131+ CREATE TABLE ` $ table_name` (
132+ `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
133+ `name` varchar(25) NOT NULL,
134+ `slug` varchar(25) NOT NULL,
135+ PRIMARY KEY (`id`),
136+ KEY `slug` (`slug`)
137+ ) $ charset_collate;
138+ " ;
139+ }
140+ };
141+ }
142+
112143 /**
113144 * Get a fake table to verify its creation.
114145 */
Original file line number Diff line number Diff line change 11<?php
22
3- namespace StellarWP \Schema \Tests \ Builder ;
3+ namespace StellarWP \Schema \Tests ;
44
55use StellarWP \Schema \Tables \Contracts \Schema_Interface as Table_Schema_Interface ;
66use StellarWP \Schema \Register ;
77use StellarWP \Schema \Schema ;
8- use StellarWP \Schema \Tests \SchemaTestCase ;
98use StellarWP \Schema \Tests \Traits \Table_Fixtures ;
109
1110class BuilderTest extends SchemaTestCase {
Original file line number Diff line number Diff line change 11<?php
2+
23namespace StellarWP \Schema \Tests ;
34
4- use lucatume \DI52 \App ;
55use StellarWP \Schema \Builder ;
66use StellarWP \Schema \Config ;
77use StellarWP \Schema \Register ;
8- use StellarWP \Schema \Tests \SchemaTestCase ;
9- use StellarWP \Schema \Tests \Traits ;
108
11- class Full_ActivationTest extends SchemaTestCase {
9+ class FullActivationTest extends SchemaTestCase {
1210 use Traits \Table_Fixtures;
1311
1412 /**
You can’t perform that action at this time.
0 commit comments