Exemplo n.º 1
0
 function testUpdate()
 {
     $name = "Stephen King";
     $test_author = new Author($name);
     $test_author->save();
     $new_name = "Neal Stephenson";
     $test_author->update($new_name);
     $this->assertEquals($new_name, $test_author->getName());
 }
Exemplo n.º 2
0
 function test_getName()
 {
     //Arrange
     $name = "J.K. Rowling";
     $test_author = new Author($name);
     //Act
     $result = $test_author->getName();
     //Assert
     $this->assertEquals($name, $result);
 }
Exemplo n.º 3
0
 function testSetname()
 {
     //Arrange
     $name = "Mary Shelly";
     $test_author = new Author($name);
     //Act
     $test_author->setName("Dean Koontz");
     $result = $test_author->getName();
     //Assert
     $this->assertEquals("Dean Koontz", $result);
 }
Exemplo n.º 4
0
 function testUpdate()
 {
     //Arrange
     $name = "JK Rowling";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $new_name = "George RR Martin";
     //Act
     $test_author->update($new_name);
     //Assert
     $this->assertEquals("George RR Martin", $test_author->getName());
 }
Exemplo n.º 5
0
 function testUpdate()
 {
     //Arrange
     $name = "Paul Jones";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $new_name = "Steve Smith";
     //Act
     $test_author->update($new_name);
     //Assert
     $this->assertEquals("Steve Smith", $test_author->getName());
 }
Exemplo n.º 6
0
 public function actionAuhtor()
 {
     if ($this->session->isLoging()) {
         echo 'Вы уже авторизированны!';
         exit;
     }
     $Author = new Author();
     if ($Author->getOneAuthor($this->params['login'], $this->params['pass'])) {
         $this->session->set('loging', 'loging');
         $this->session->set('author_id', $Author->getAuthorId());
         $this->session->set('login', $Author->getLogin());
         $this->session->set('pass', $Author->getPass());
         $this->session->set('logo', $Author->getLogo());
         $this->session->set('name', $Author->getName());
     }
     $this->view = new View($this->params, PATH_VIEW_MESSAGE, 'welcom_tpl.php', false);
     $this->html->add('content', $this->view->render());
     $layout = new Layout($this->html->getArray());
     $layout->get();
 }
Exemplo n.º 7
0
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors)
{
    $p_errors = array();
    $articles = Article::GetArticlesOfType($p_sourceField->getArticleType());
    foreach ($articles as $article) {
        $articleData = $article->getArticleData();
        $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName()));
        if (empty($authorName)) {
            continue;
        }
        $author = new Author($authorName);
        if (!$author->exists()) {
            if (!$author->create()) {
                $p_errors[] = getGS('Unable to create author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType());
                continue;
            }
        }
        if (!$article->setAuthorId($author->getId())) {
            $p_errors[] = getGS('Error setting the author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType());
            continue;
        }
    }
    return count($p_errors);
}
Exemplo n.º 8
0
 function test_update()
 {
     //Arrange
     $name = "Steve";
     $test_author = new Author($name);
     $test_author->save();
     //Act
     $new_name = "Bob";
     $test_author->update($new_name);
     $result = $test_author->getName();
     //Assert
     $this->assertEquals($new_name, $result);
 }
Exemplo n.º 9
0
 function testUpdate()
 {
     //Arrange
     $name = "Name";
     $test_author = new Author($name);
     $test_author->save();
     $new_name = "New Name";
     //Act
     $test_author->update($new_name);
     //Assert
     $this->assertEquals($test_author->getName(), $new_name);
 }
Exemplo n.º 10
0
 public function testUpdateObject()
 {
     $newAuthor = new Author();
     $newAuthor->setName('James Joyce');
     $newAuthor->setCreationDatetime(date('Y-m-d H:i:s'));
     $newAuthor->save();
     $newAuthor->setName('Mark Twain');
     $this->assertIdentical($newAuthor->getName(), 'Mark Twain');
     $newAuthor->save();
     $sameAuthor = Author::constructByKey($newAuthor->getAuthorId());
     $this->assertIdentical($sameAuthor->getName(), 'Mark Twain');
 }
Exemplo n.º 11
0
 function testUpdateName()
 {
     //Arrange
     $name = "Stephen King";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $new_name = "James Patterson";
     //Act
     $test_author->updateName($new_name);
     //Assert
     $this->assertEquals("James Patterson", $test_author->getName());
 }
Exemplo n.º 12
0
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
$fixtures = 'fixtures/fixtures.yml';
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$t = new lime_test(22);
$authors = Doctrine_Core::getTable('Author')->findAll();
$t->is(count($authors), 2);
$author = new Author();
// Accessor overriding
$author->setName('Jonathan H. Wage');
$author->save();
// Propel style accessors with column name
$t->is($author->getName(), $author->name);
// Propel style accessors for id
// Also check new author was not created since Jonathan H. Wage exists in fixtures/fixtures.yml
$t->is($author->getId(), 1);
// Make sure we still have only 2 authors
$authors = Doctrine_Core::getTable('Author')->findAll();
$t->is(count($authors), 2);
$article = new Article();
$article->title = 'test';
// __toString() automatic column finder
$t->is((string) $article, 'test');
// Different style accessors
$t->is($article->getAuthor_id(), $article->author_id);
$t->is($article->getAuthorId(), $article->author_id);
$t->is($article->getauthorId(), $article->author_id);
$t->is($article->getAuthorID(), $article->author_id);
Exemplo n.º 13
0
 function test_searchAuthor()
 {
     $name = "Jerry Garcia";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Frank Sinatra";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $result = Author::searchAuthor($test_author->getName());
     $this->assertEquals($test_author, $result);
 }
Exemplo n.º 14
0
        $image = Image::OnImageUpload($_FILES['file'], $attributes);
        if (PEAR::isError($image)) {
            camp_html_add_msg($image->getMessage());
        } else {
            $author->setImage($image->getImageId());
        }
    }

    $aliases = Input::Get("alias", "array");
    if (!empty($aliases)) {
        $author->setAliases($aliases);
    }

    if ($isNewAuthor) {
        $logtext = getGS('New author "$1" ($2) created.',
            $author->getName(), $author->getId());
        Log::Message($logtext, $g_user->getUserId(), 172);
    } else {
        $logtext = getGS('Author information has been changed for "$1" ($2)',
            $author->getName(), $author->getId());
        Log::Message($logtext, $g_user->getUserId(), 173);
    }
    camp_html_add_msg(getGS("Author saved."),"ok");
} elseif ($del_id_alias < 1 && $id > -1 && !$can_save) {
    camp_html_add_msg(getGS("Please fill at least first name and last name."));
}

if (!$id || $id == -1) {
    $author = new Author(1);
    if ($id == -1) {
        $id = 0;
Exemplo n.º 15
0
 /**
  * @return string
  */
 public function showName()
 {
     return $this->html($this->author->getName());
 }
Exemplo n.º 16
0
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors)
{
    $translator = \Zend_Registry::get('container')->getService('translator');
    $p_errors = array();
    $articles = Article::GetArticlesOfType($p_sourceField->getArticleType());
    foreach ($articles as $article) {
        $articleData = $article->getArticleData();
        $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName()));
        if (empty($authorName)) {
            continue;
        }
        $author = new Author($authorName);
        if (!$author->exists()) {
            if (!$author->create()) {
                $p_errors[] = $translator->trans('Unable to create author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
                continue;
            }
        }
        if (!$article->setAuthorId($author->getId())) {
            $p_errors[] = $translator->trans('Error setting the author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home');
            continue;
        }
    }
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $cacheService->clearNamespace('authors');
    $cacheService->clearNamespace('article');
    return count($p_errors);
}
Exemplo n.º 17
0
 function test_update()
 {
     //Arrange
     $name = "Ashlin Aronin";
     $test_author = new Author($name);
     $test_author->save();
     //Act
     $new_name = "Sassy Ash";
     $test_author->update($new_name);
     //Assert
     $this->assertEquals($new_name, $test_author->getName());
 }
Exemplo n.º 18
0
 function testUpdate()
 {
     //Arrange
     $name = "Nathan Young";
     $id = null;
     $test_author = new Author($name, $id);
     $test_author->save();
     $new_name = "Kyle Pratuch";
     //Act
     $test_author->update($new_name);
     //Assert
     $this->assertEquals("Kyle Pratuch", $test_author->getName());
 }
Exemplo n.º 19
0
 function testUpdate()
 {
     //Arrange
     $id = null;
     $name = "lemony snicket";
     $test_author = new Author($id, $name);
     $test_author->save();
     $new_name = "Lemony Snicket";
     //Act
     $test_author->update($new_name);
     //Assert
     $this->assertEquals($test_author->getName(), $new_name);
 }
Exemplo n.º 20
0
 public function testConstructorWithFormatRFC822()
 {
     $author = new Author('James Bond <*****@*****.**>');
     $this->assertSame('James Bond', $author->getName());
     $this->assertSame('*****@*****.**', $author->getEmail());
 }