From a851dd35b8ead5e4688062ff0c6e94d83133b006 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 15 Apr 2021 22:22:40 +0200 Subject: Refactor Band::create into Band::find and ::create Not sure if it's a good idea to have `create` return an existing band. Will have to look at callsites to see if it should be renamed back or if the callsite should be changed. --- tests/BandTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/BandTest.php b/tests/BandTest.php index 764abe3..d3feb51 100644 --- a/tests/BandTest.php +++ b/tests/BandTest.php @@ -10,7 +10,7 @@ require __DIR__ . '/../includes/band.php'; final class BandTest extends WP_UnitTestCase { - public function testCreatingBandWithName(): void + public function testCreatingBandWithName() : void { $count = count(GiglogAdmin_Band::all_bands()); @@ -19,4 +19,12 @@ final class BandTest extends WP_UnitTestCase $this->assertEquals("The Flamboyant Blasphemers", $band->bandname()); $this->assertEquals($count + 1, count(GiglogAdmin_Band::all_bands())); } + + public function testCreateExistingBand() : void + { + $band1 = GiglogAdmin_Band::create("The Flamboyant Blasphemers"); + $band2 = GiglogAdmin_Band::create("The Flamboyant Blasphemers"); + + $this->assertEquals($band1->id(), $band2->id()); + } } -- cgit v1.2.3