Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 5th, 2012  |  syntax: PHP  |  size: 1.61 KB  |  views: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /* Enterprise Test cases generated on: 2012-09-28 21:53:19 : 1348883599*/
  3. App::uses('Model', 'Model');
  4.  
  5. class Enterprise extends Model {
  6.     public function subscribe() {
  7.         echo 'Subscription ID: ';
  8.         var_dump($this->field('subscription_id'));
  9.         echo 'Name: ';
  10.         var_dump($this->field('name'));
  11.     }
  12. }
  13.  
  14. /**
  15.  * Enterprise Test Case
  16.  *
  17.  */
  18. class EnterpriseSOTestCase extends CakeTestCase {
  19. /**
  20.  * setUp method
  21.  *
  22.  * @return void
  23.  */
  24.         public function setUp() {
  25.                 parent::setUp();
  26.         }
  27.  
  28. /**
  29.  * tearDown method
  30.  *
  31.  * @return void
  32.  */
  33.         public function tearDown() {
  34.                 parent::tearDown();
  35.         }
  36.  
  37. /**
  38.  * testSubscribe method
  39.  *
  40.  * @return void
  41.  */
  42.         public function testValueMap() {
  43.         // Subscribe new customer.
  44.         $enterprise = $this->getMock('Enterprise', array('field'));
  45.         $enterprise->expects($this->any())
  46.             ->method('field')
  47.             ->will($this->returnValueMap(array(
  48.                 array('subscription_id', null),
  49.                 array('name', 'Monday Farms')
  50.             )));
  51.         $enterprise->subscribe();
  52.     }
  53.  
  54.         public function testCallback() {
  55.         // Subscribe new customer.
  56.         $enterprise = $this->getMock('Enterprise', array('field'));
  57.         $enterprise->expects($this->any())
  58.             ->method('field')
  59.             ->will($this->returnCallback(function ($arg) {
  60.                 $map = array(
  61.                     'subscription_id' => null,
  62.                     'name' => 'Monday Farms'
  63.                 );
  64.                 return $map[$arg];
  65.             }));
  66.         $enterprise->subscribe();
  67.     }
  68.  
  69. }