public function testMultipleCompaniesForTheSamePayees() { $this->resetEvents(); $path = $this->copyFileToTemp($this->fileName()); $s = $this->service(); $companyId1 = rand(1000, 1000000); $companyId2 = rand(1000, 1000000); $fileDetails = ["year" => 2015, "month" => 7]; $rpf = $s->process($path, $companyId1, $fileDetails); $this->assertTrue($rpf->status == RoyaltyPaymentFile::STATUS_PAYMENTS_PROCESSED); $path = $this->copyFileToTemp($this->fileName()); $rpf = $s->process($path, $companyId2, $fileDetails); $this->assertTrue($rpf->status == RoyaltyPaymentFile::STATUS_PAYMENTS_PROCESSED); $payees = User::all(); $this->assertTrue(count($payees) == 2); $payee1 = $payees[0]; $this->assertTrue($payee1->id == 1); $this->assertTrue($payee1->company_id == $companyId1); $this->assertTrue($payee1->type == "payee"); $this->assertTrue($payee1->email == null); $this->assertTrue($payee1->code == "1175"); $this->assertTrue($payee1->name == "Studio 51"); $payee2 = $payees[1]; $this->assertTrue($payee2->id == 2); $this->assertTrue($payee2->company_id == $companyId1); $this->assertTrue($payee2->type == "payee"); $this->assertTrue($payee2->email == null); $this->assertTrue($payee2->code == "1379"); $this->assertTrue($payee2->name == "Pop Virus (PACIFICA)"); $payeeCompany = PayeeCompany::all(); $this->assertTrue(count($payeeCompany) == 4); $this->assertTrue($payeeCompany[0]->user_id == 1); $this->assertTrue($payeeCompany[0]->code == 1175); $this->assertTrue($payeeCompany[0]->company_id == $companyId1); $this->assertTrue($payeeCompany[1]->user_id == 2); $this->assertTrue($payeeCompany[1]->code == 1379); $this->assertTrue($payeeCompany[1]->company_id == $companyId1); $this->assertTrue($payeeCompany[2]->user_id == 1); $this->assertTrue($payeeCompany[2]->code == 1175); $this->assertTrue($payeeCompany[2]->company_id == $companyId2); $this->assertTrue($payeeCompany[3]->user_id == 2); $this->assertTrue($payeeCompany[3]->code == 1379); $this->assertTrue($payeeCompany[3]->company_id == $companyId2); $path = $this->copyFileToTemp($this->fileName()); $rpf = $s->process($path, $companyId2, $fileDetails); $this->assertTrue($rpf->status == RoyaltyPaymentFile::STATUS_PAYMENTS_PROCESSED); $payeeCompany = PayeeCompany::all(); $this->assertTrue(count($payeeCompany) == 4); $this->assertTrue($payeeCompany[0]->user_id == 1); $this->assertTrue($payeeCompany[0]->code == 1175); $this->assertTrue($payeeCompany[0]->company_id == $companyId1); $this->assertTrue($payeeCompany[1]->user_id == 2); $this->assertTrue($payeeCompany[1]->code == 1379); $this->assertTrue($payeeCompany[1]->company_id == $companyId1); $this->assertTrue($payeeCompany[2]->user_id == 1); $this->assertTrue($payeeCompany[2]->code == 1175); $this->assertTrue($payeeCompany[2]->company_id == $companyId2); $this->assertTrue($payeeCompany[3]->user_id == 2); $this->assertTrue($payeeCompany[3]->code == 1379); $this->assertTrue($payeeCompany[3]->company_id == $companyId2); $this->resetEvents(); }