예제 #1
0
 /**
  * Sets up required mocks and the CommentStatistics service under test.
  */
 protected function setUp()
 {
     $this->statement = $this->getMockBuilder('Drupal\\Core\\Database\\Driver\\sqlite\\Statement')->disableOriginalConstructor()->getMock();
     $this->statement->expects($this->any())->method('fetchObject')->will($this->returnCallback(array($this, 'fetchObjectCallback')));
     $this->select = $this->getMockBuilder('Drupal\\Core\\Database\\Query\\Select')->disableOriginalConstructor()->getMock();
     $this->select->expects($this->any())->method('fields')->will($this->returnSelf());
     $this->select->expects($this->any())->method('condition')->will($this->returnSelf());
     $this->select->expects($this->any())->method('execute')->will($this->returnValue($this->statement));
     $this->database = $this->getMockBuilder('Drupal\\Core\\Database\\Connection')->disableOriginalConstructor()->getMock();
     $this->database->expects($this->once())->method('select')->will($this->returnValue($this->select));
     $this->commentStatistics = new CommentStatistics($this->database, $this->getMock('Drupal\\Core\\Session\\AccountInterface'), $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface'), $this->getMock('Drupal\\Core\\State\\StateInterface'));
 }
예제 #2
0
 /**
  * @covers ::getUid
  * @covers ::__construct
  */
 function testGetUid()
 {
     $actual_data = (object) ["uid" => 2];
     $this->statement->expects($this->any())->method('fetchObject')->will($this->returnValue($actual_data));
     $authmap = new Authmap($this->connection);
     $result = $authmap->getUid(2, "test_provider");
     $this->assertEquals(2, $result);
 }
예제 #3
0
 protected function __construct(Connection $dbh) {
   $this->allowRowCount = TRUE;
   parent::__construct($dbh);
 }