PHP Classes

File: tests/model/UserTest.php

Recommend this page to a friend!
  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: Update of tests/model/UserTest.php
Date: 7 months ago
Size: 1,059 bytes
 

Contents

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

   
$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()));
  }
}