diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-04-10 15:24:51 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-04-14 21:21:16 +0200 |
commit | a17c5b5f05ca4c7cf4f0d0d640f95ae283b1796a (patch) | |
tree | 4ece4b944cae0316eed272a2f44b304142a4d912 /tests/VenueTest.php | |
parent | 558544fcef3335216d225bb587129a424db8d7af (diff) | |
download | gigologadmin-a17c5b5f05ca4c7cf4f0d0d640f95ae283b1796a.tar.gz gigologadmin-a17c5b5f05ca4c7cf4f0d0d640f95ae283b1796a.tar.bz2 gigologadmin-a17c5b5f05ca4c7cf4f0d0d640f95ae283b1796a.zip |
Use (object) notation to create plain objects.
Diffstat (limited to 'tests/VenueTest.php')
-rw-r--r-- | tests/VenueTest.php | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/tests/VenueTest.php b/tests/VenueTest.php index e886167..bea6dc4 100644 --- a/tests/VenueTest.php +++ b/tests/VenueTest.php @@ -31,19 +31,22 @@ final class VenueTest extends TestCase { global $wpdb; - $v = new stdClass(); - $v->id = 42; - $v->wpgvenue_name = 'Slarkhaillen'; - $v->wpgvenue_city = 'Ofoten'; - $v->wpgvenue_address = 'Baillsvingen 4'; - $v->wpgvenue_webpage = 'https://slarkhaillen.no'; + $results = array( + (object) [ + 'id' => 42, + 'wpgvenue_name' => 'Slarkhaillen', + 'wpgvenue_city' => 'Ofoten', + 'wpgvenue_address' => 'Baillsvingen 4', + 'wpgvenue_webpage' => 'https://slarkhaillen.no' + ]); $wpdb = $this->createStub(wpdb::class); - $wpdb->method('get_results')->willReturn(array($v)); + $wpdb->method('get_results')->willReturn($results); + $venue = GiglogAdmin_Venue::find_or_create("Slarkhaillen"); - $this->assertEquals(42, $venue->id()); - $this->assertEquals($v->wpgvenue_name, $venue->name()); + $this->assertEquals($results[0]->id, $venue->id()); + $this->assertEquals($results[0]->wpgvenue_name, $venue->name()); } public function testFindAllVenuesInCity() : void @@ -52,10 +55,11 @@ final class VenueTest extends TestCase $results = array(); for ($i = 0; $i < 3; $i++) { - $results[$i] = new stdClass(); - $results[$i]->id = 42 + $i; - $results[$i]->wpgvenue_name = "Venue #" . $i; - $results[$i]->wpgvenue_city = "Osaka"; + $results[$i] = (object) [ + 'id' => 42 + $i, + 'wpgvenue_name' => "Venue #" . $i, + 'wpgvenue_city' => "Osaka" + ]; } $wpdb = $this->createStub(wpdb::class); @@ -77,10 +81,11 @@ final class VenueTest extends TestCase $results = array(); for ($i = 0; $i < 3; $i++) { - $results[$i] = new stdClass(); - $results[$i]->id = 42 + $i; - $results[$i]->wpgvenue_name = "Venue #" . $i; - $results[$i]->wpgvenue_city = "City #" . $i; + $results[$i] = (object) [ + 'id' => 42 + $i, + 'wpgvenue_name' => "Venue #" . $i, + 'wpgvenue_city' => "City #" . $i + ]; } $wpdb = $this->createStub(wpdb::class); |