public function testPersistInsertsNewAccountsIntoTheDatabaseMockedVersion()
 {
     $stmt = $this->mock('stdClass')->execute([500], $this->once())->new();
     $pdo = $this->mock('PDO')->prepare(['insert into account (balance) values (?)'], $stmt, $this->once())->lastInsertId(1, $this->once())->new('sqlite::memory:');
     $service = new BankAccountService($pdo);
     $account = new BankAccount();
     $account->deposit(500);
     $newAccountId = $service->persist($account);
     $this->assertEquals(1, $newAccountId);
 }
 public function testPersistInsertsNewAccountsIntoTheDatabaseMockedVersion()
 {
     $stmt = $this->getMockBuilder('stdClass')->setMethods(['execute'])->getMock();
     $stmt->expects($this->once())->method('execute')->with([500]);
     $pdo = $this->getMockBuilder('PDO')->setConstructorArgs(['sqlite::memory:'])->getMock();
     $pdo->expects($this->once())->method('prepare')->with('insert into account (balance) values (?)')->will($this->returnValue($stmt));
     $pdo->expects($this->once())->method('lastInsertId')->will($this->returnValue(1));
     $service = new BankAccountService($pdo);
     $account = new BankAccount();
     $account->deposit(500);
     $newAccountId = $service->persist($account);
     $this->assertEquals(1, $newAccountId);
 }