WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#42672 closed defect (bug) (worksforme)

Unexpected incorrect usage notice for wpdb::prepare in wordpress test lib

Reported by: skarabeq Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

When I use phpunit for wordpress with factory like as:

<?php
public function testCategory()
    {
        // Create category
        $category = $this->factory()->term->create([
            'name'     => 'Test',
            'taxonomy' => 'category'
        ]);

        $this->assertTrue(is_int($category) ? true : false);
    }

I got error

Unexpected incorrect usage notice for wpdb::prepare
Failed asserting that an array is empty.

I tested it with wordpress test lib 4.8.1, 4.8.2 , 4.8.3 and 4.9. Only 4.8.1 and 4.8.2 is works as expected. After version 4.8.2 I think you are changes something and all tests who used factory create are broken. I am very disappointed with this!

Change History (5)

#1 @skarabeq
2 years ago

  • Severity changed from normal to blocker

#2 @bor0
2 years ago

Cannot reproduce this on https://develop.svn.wordpress.org/trunk.

PHPUnit 5.7.25 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 1.59 seconds, Memory: 36.00MB

OK (1 test, 1 assertion)

#3 @swissspidy
2 years ago

  • Severity changed from blocker to normal

Failed asserting that an array is empty.

That doesn't match the assertion $this->assertTrue(is_int($category) ? true : false); (which btw should just be $this->assertTrue(is_int($category)); or $this->assertInternalType( 'int', $category );).

Are you sure the error is caused by this method?

#4 @skarabeq
2 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

#5 @netweb
2 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.