3v4l.org

run code in 300+ PHP versions simultaneously
<?php //SUT /** * @param array $personArray * * @return int The number of rows affected. (Should be 1) */ public function addPerson(Array $personArray) { /** @var Doctrine\DBAL\Connection $conn */ $conn = clone $this->conn; $personArray['crew_start_date'] = (new \DateTime($personArray['crew_start_date']))->getTimestamp(); return $conn->transactional(function() use($conn, $personArray){//How do I get code coverage inside this closure? $inputValues = array_merge([ 'crew_given_name' => null, 'crew_family_name' => null, 'crew_start_date' => null, 'crew_end_date' => null, ], $personArray); return $conn->insert('mqiv_crew', $inputValues, [\PDO::PARAM_STR, \PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT]); }); } //The test public function testCanAddPerson() { $mockDb = clone $this->mockDb; $mockDb->expects($this->any()) ->method('transactional') ->will($this->returnValue(1)); $testConnector = new SqlConnector($mockDb, $this->getMockBuilders()); $testPersonArray = [ 'crew_given_name' => 'testy', 'crew_family_name' => 'testing', 'crew_start_date' => '01/01/2014', 'crew_end_date' => '02/01/2014', ]; $this->assertEquals(1, $testConnector->addPerson($testPersonArray), "Could not add person"); }
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/NSiPp on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_PUBLIC in /in/NSiPp on line 8
Process exited with code 255.

preferences:
174.75 ms | 1395 KiB | 64 Q