Login   Register  
PHP Classes
elePHPant
Icontem

File: tests/model/UserTest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gjero Krsteski  >  Building an Identity Map in PHP  >  tests/model/UserTest.php  >  Download  
File: tests/model/UserTest.php
Role: Unit test script
Content type: text/plain
Description: user model test
Class: Building an Identity Map in PHP
Retrieve objects avoiding multiple instances
Author: By
Last change: refactoring of models and data-mappers
Merge remote-tracking branch 'origin/master'

Conflicts:
.gitignore
add One-to-Many Relationships in Databases
add One-to-Many Relationships in Databases
Date: 1 year ago
Size: 1,059 bytes
 

Contents

Class file image Download
<?php
class UserTest extends PHPUnit_Framework_TestCase
{
  
/**
   * @test
   */
  
public function CreatingNewInstance()
  {
    
$user = new User(nullnull);

    
$reflectedUser = new ReflectionClass(get_class($user));

    
$this->assertTrue($reflectedUser->hasProperty('nickname'));
    
$this->assertEquals(null$user->getNickname());

    
$this->assertTrue($reflectedUser->hasProperty('password'));
    
$this->assertEquals(null$user->getPassword());
  }

  
/**
   * @test
   */
  
public function InstanceNoException()
  {
    
$newUser = new User('maxf''love123');

    
$this->assertEquals('love123'$newUser->getPassword());
  }

  
/**
   * @test
   */
  
public function AddSomeArticles()
  {
    
$newUser = new User('Conan''He rocks!');

    
$this->assertFalse($newUser->hasArticles());

    
$newUser->addArticle('Conan I''Some content about conan')
            ->
addArticle('Conan I''Some content about conan');

    
$this->assertTrue($newUser->hasArticles());
    
$this->assertInstanceOf('Article'current($newUser->getArticles()));
  }
}