public function testIsAuthorizedReturnsFalseWhenClientHasDifferentCourse()
 {
     $courseProductId = 33;
     $courseCode = 'MYCOURSE';
     $clientId = 15;
     $otherCourseProductId = 35;
     $otherCourseCode = 'OTHERCOURSE';
     $clientPeerMock = $this->getClientPeerMock($clientId);
     $clientProductMock = $this->getClientProductMock($otherCourseProductId, $otherCourseCode);
     $clientQueryMock = $this->getClientQueryMock($clientId, [$clientProductMock]);
     Factory::injectObject(ClientPeer::class, $clientPeerMock);
     Factory::injectQueryObject(ClientQuery::class, $clientQueryMock);
     $course = new Course();
     $course->setBillingProductId($courseProductId);
     $this->assertEquals(0, $course->isAuthorized());
 }
 public function testFilterByClientIdLimitsByRelatedUserIds()
 {
     $clientId = 8828;
     $userId1 = 299382;
     $userId2 = 111883;
     $userMock1 = $this->getUserMock($userId1);
     $userMock2 = $this->getUserMock($userId2);
     $userCollection = new PropelCollection();
     $userCollection->setData([$userMock1, $userMock2]);
     $userQueryMock = $this->getMock(UserQuery::class, ['findByBillingClientId']);
     $userQueryMock->expects($this->any())->method('findByBillingClientId')->with($this->equalTo($clientId))->willReturn($userCollection);
     Factory::injectQueryObject(UserQuery::class, $userQueryMock);
     $query = $this->getMock(QuestionQuery::class, ['filterByAuthUserId']);
     $query->expects($this->once())->method('filterByAuthUserId')->with($this->equalTo([$userId1, $userId2]));
     $query->filterByClientId($clientId);
 }
Ejemplo n.º 3
0
 public function testInjectQueryObjectCausesMockToReturnFromCreateNewQueryObject()
 {
     $queryMock = $this->getMock(stdClass::class, []);
     Factory::injectQueryObject(stdClass::class, $queryMock);
     $this->assertEquals($queryMock, Factory::createNewQueryObject(stdClass::class));
 }