public function testReadAccessorsReturnPropertiesValues() { $value = 'bob'; $type = new TokenType(TokenType::DYNAMIC_ARRAY_TYPE); $token = new Token($value, $type); $this->assertEquals($value, $token->getValue()); $this->assertEquals($type->getValue(), $token->getType()); $this->assertEquals('(DYNAMIC_ARRAY_TYPE) bob', $token->__toString()); }
public function testToString() { $p = new Position(5, 10); $t = new Token(Token::IDENTIFIER, "ident", $p); $this->assertEquals("<'ident', IDENTIFIER, (5, 10)>", $t->__toString()); $p = new Position(5, 10, "/foo/bar.ebnf"); $t = new Token(Token::IDENTIFIER, "ident", $p); $this->assertEquals("<'ident', IDENTIFIER, /foo/bar.ebnf (5, 10)>", $t->__toString()); $p = new Position(5, 10, "/foo/bar.ebnf"); $t = new Token(Token::IDENTIFIER, "", $p); $this->assertEquals("<IDENTIFIER, /foo/bar.ebnf (5, 10)>", $t->__toString()); $p = new Position(5, 10, "/foo/bar.ebnf"); $t = new Token(Token::IDENTIFIER, "a-very-very-very-very-long-identifier", $p); $this->assertEquals("<'a-very-very-ver...', IDENTIFIER, /foo/bar.ebnf (5, 10)>", $t->__toString()); }
/** * Main function: does the backup */ private function go() { $this->phpflickr = new oPhpFlickr($this->appid, $this->secret, true); // Check for Flickr username if ($this->flickr_username != false) { $this->dialog->info(1, "Looking for Flickr id for username {$this->flickr_username}"); $r = $this->phpflickr->people_findByUsername($this->flickr_username); $this->flickr_id = $r['nsid']; } // Check for Flickr ID if (!$this->flickr_id) { $this->dialog->error("Missing Flickr ID"); exit(1); } // Create phpFlickr object $ini_array = parse_ini_file($this->configuration_file, true); if (!is_array($ini_array) || !is_array($ini_array[$this->flickr_id]) || !$ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN] || !$ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN_SECRET]) { $this->dialog->info(1, "No information about Flickr id {$this->flickr_id} in configuration file {$this->configuration_file}"); $token = $this->authorize(); } else { $token = new Token($ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN], $ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN_SECRET]); } if (!$token || $token->getToken() == '' || $token->getSecret() == '') { $this->dialog->error("No access token for Flickr id {$this->flickr_id} in configuration file {$this->configuration_file}: " . $token->__toString()); exit(1); } $this->phpflickr->setToken($token); // Do the backup if ($this->backup_all_photos) { $this->get_photo_list(); } $this->backup_photos(); if ($this->backup_all_sets) { $this->get_set_list(); } $this->backup_sets(); }