Commit graph

13 commits

Author SHA1 Message Date
Aaron Schulz
1f1fbaa026 rdbms: make DatabasePostgresTest use addDBDataOnce() and use tableName()
This matches how raw queries normally use quoted table names

Change-Id: I9344135777f08dc064b01d19fd190c0c98bd2b67
2023-12-11 00:31:11 +00:00
Reedy
e57f6e20d2 DatabasePostgresTest: Replace ${var} usages
Change-Id: I48ec8635044b8ea762bf9d6a7b9bac2e3bfbd7e1
2023-08-22 18:17:48 +00:00
Daimona Eaytoy
c1298c9ed8 Make some methods static in MediaWikiIntegrationTestCase
Mostly things related to the test database. Also adjust visibility and
remove getTestPrefixFor(), which is only used in core according to
codesearch.

Making a method static is a backwards compatible change, as invoking the
method non-statically is valid.

Bug: T342259
Change-Id: I6111fb5ff5f3c87d5d3f9188b3f50351391a29c3
2023-08-15 20:53:13 +00:00
Amir Sarabadani
95746494bf tests: Switch to SelectQueryBuilder in Sqlite and PG integration tests
Bug: T311866
Change-Id: Icd803be5d9e5408ceb180b11fd44b8be45a89c44
2023-07-20 13:01:37 +02:00
Aaron Schulz
f838289281 rdbms: make affectedRows() count each updated row in replace() as one
Previously, DatabaseMysqli/DatabasePostgres would count such updates as two.

Bug: T314100
Change-Id: I541c12cee99c66911337192d3f516f6e49f775c3
2023-05-30 17:31:28 -07:00
Aaron Schulz
924d1f0374 rdbms: make IDatabase::insertId() less fragile and more consistent
Track the insert ID value in Database, similar to the affected rows.
This makes it possible for subclasses to stash or override the value,
which is useful when emulating a write operation using multiple queries.
This includes the case of internal use of atomic sections, where the
COMMIT/RELEASE can reset the last_insert_id tracked in the PECL driver
itself.

Use separate methods and fields for "last query statement" information
and "last query method" information.

Make insertId() for SQLite and Postgres better match MySQL:
* Return 0 if the last query statement did not change any rows.
  This helps protect against callers that fail to check affectedRows().
* Make it return the existing ROWID/SERIAL column when upsert() updates
  an existing row. This adds a new getInsertIdColumnForUpsert() helper
  function.

Directly use query() in doReplace() and doInsertSelectGeneric() to make
the affected row/ID logic easier to follow.

Improve insertId() and affectedRows() documentation.

Add more integration tests of row insertion methods.

Bug: T314100
Change-Id: I7d43a2e52260e66acb713554bb883f5f4a14d010
2023-05-26 19:01:45 -07:00
Amir Sarabadani
7ffd35ecc6 rdbms: Remove Database::attributesFromType and hard-deprecate ::factory
They have been soft-deprecated since 1.39 and the first one is not used
anywhere, ::factory is used in some third party code but not in
Wikimedia-deployed ones

Change-Id: Icd0f743d9c76554dd02471485ee732e25b9fb932
2023-02-23 17:59:54 +00:00
Umherirrender
770f905900 tests: Use namespaced IDatabase class
Change-Id: I7171ff26faee00d9eaabc33c2f3d91049ea0b40d
2022-05-28 00:09:55 +02:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
Timo Tijhof
1c11a5071b tests: Disable the broken ignore and cases of DatabasePostgresTest
These four test cases have been broken for months:
- testInsertIgnoreOld
- testInsertIgnoreNew
- testInsertSelectIgnoreOld
- testInsertSelectIgnoreNew

Disabling now to unblock T246358.

Bug: T246358
Bug: T259084
Change-Id: Idd1e920de8759d8795788572139c8528af05bd2c
2020-07-29 00:23:27 +01:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
Aaron Schulz
13b11a946e rdbms: reduce duplication in Database via helper methods
Add several new internal methods to help with wrangling
the various formats that rows, conditions, options, and
unique key lists can come in. Remove now unused method
isMultiRowArray().

Add various sanity checks and logging for parameters to
upsert(), replace(), insert(), and insertSelect().

Move DatabasePostgresTest to the integration/ directory.

Change-Id: If5988a6f0816e8da2cbf2fd612e1a3e3a2e9c52f
2020-03-10 22:26:04 +00:00
Renamed from tests/phpunit/includes/db/DatabasePostgresTest.php (Browse further)