assertInstanceOf(Set::class, $set); $this->assertEquals(2, $set->amount); $this->assertEquals('red', $set->color); // Test input with extra whitespace $input = " 3 blue "; $set = Set::fromStringInput($input); $this->assertInstanceOf(Set::class, $set); $this->assertEquals(3, $set->amount); $this->assertEquals('blue', $set->color); } /** * Test case for the fromInputList method of the Set class. */ public function testFromInputList() { $input = "2 Black,3 White,4 Red"; $sets = Set::fromInputList($input); $this->assertIsArray($sets); $this->assertCount(3, $sets); $this->assertInstanceOf(Set::class, $sets[0]); $this->assertSame(2, $sets[0]->amount); $this->assertSame('Black', $sets[0]->color); $this->assertInstanceOf(Set::class, $sets[1]); $this->assertSame(3, $sets[1]->amount); $this->assertSame('White', $sets[1]->color); $this->assertInstanceOf(Set::class, $sets[2]); $this->assertSame(4, $sets[2]->amount); $this->assertSame('Red', $sets[2]->color); } }