function testMendeleyWithCustomConstructorWorks()
 {
     $consumer = Configuration::getConsumer();
     $mendeley = new Mendeley($consumer['key'], $consumer['secret']);
     $groupId = 164791;
     $url = 'groups/' . $groupId;
     $params = array('page' => 1, 'items' => 1);
     $result = $mendeley->get($url, $params);
     $this->assertEqual((int) $result->group_id, $groupId);
 }
Example #2
0
 /**
  * @param string
  * 	consumer key, you may optionally give a consumer key and secret to the class constructor which overrides the default values in the configuration file.
  * @param string
  * 	consumer secret
  */
 public function __construct($consumerKey = null, $consumerSecret = null)
 {
     require_once 'Configuration.php';
     require_once Configuration::getPathToOauth();
     if (!empty($consumerKey) && !empty($consumerSecret)) {
         $consumer = array('key' => $consumerKey, 'secret' => $consumerSecret);
     } else {
         $consumer = Configuration::getConsumer();
     }
     $this->consumer = new OAuthConsumer($consumer['key'], $consumer['secret'], null);
     $this->signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
     $this->cache = new MendeleyCache('_' . md5($this->consumer->key));
 }
 function testCacheSetAndGet()
 {
     $name = 'test';
     $value = 123;
     $consumer = Configuration::getConsumer();
     $suffix = '_' . md5($consumer['key']);
     $cache = new MendeleyCache($suffix);
     $dir = $cache->getDir();
     $cache->del($name);
     $this->assertFalse(file_exists($dir . $name . $suffix));
     $cache->set($name, $value);
     $this->assertTrue(file_exists($dir . $name . $suffix));
     $test = $cache->get($name);
     $this->assertTrue($test === $value);
     $cache->del($name);
     $this->assertFalse(file_exists($dir . $name . $suffix));
 }