예제 #1
0
 public function AddAccessory()
 {
     $name = $this->page->GetAccessoryName();
     $quantity = $this->page->GetQuantityAvailable();
     Log::Debug('Adding new accessory with name %s and quantity %s', $name, $quantity);
     $this->accessoryRepository->Add(Accessory::Create($name, $quantity));
 }
 public function testCanAdd()
 {
     $name = 'n';
     $available = 100;
     $accessory = Accessory::Create($name, $available);
     $command = new AddAccessoryCommand($name, $available);
     $this->repository->Add($accessory);
     $this->assertEquals($command, $this->db->_LastCommand);
 }
 public function testWhenAdding()
 {
     $name = 'accessory';
     $quantity = 2;
     $expectedAccessory = Accessory::Create($name, $quantity);
     $this->page->expects($this->once())->method('GetAccessoryName')->will($this->returnValue($name));
     $this->page->expects($this->once())->method('GetQuantityAvailable')->will($this->returnValue($quantity));
     $this->accessoryRepository->expects($this->once())->method('Add')->with($this->equalTo($expectedAccessory));
     $this->presenter->AddAccessory();
 }
예제 #4
0
 public function run()
 {
     // Initialize empty array
     $accessory = array();
     $date = new DateTime();
     $accessory[] = array('name' => 'Cisco Desktop Phone', 'category_id' => 4, 'qty' => '20', 'requestable' => '0', 'user_id' => 1);
     $accessory[] = array('name' => 'ASUS 23-inch', 'category_id' => 5, 'qty' => '20', 'requestable' => '0', 'user_id' => 1);
     // Delete all the old data
     DB::table('accessories')->truncate();
     // Insert the new posts
     Accessory::insert($accessory);
 }
예제 #5
0
 public function __construct(IRestServer $server, Accessory $accessory)
 {
     $this->id = $accessory->GetId();
     $this->name = $accessory->GetName();
     $this->quantityAvailable = $accessory->GetQuantityAvailable();
 }
예제 #6
0
 /**
  * @param Accessory $accessory
  * @return void
  */
 public function Update(Accessory $accessory)
 {
     ServiceLocator::GetDatabase()->Execute(new UpdateAccessoryCommand($accessory->GetId(), $accessory->GetName(), $accessory->GetQuantityAvailable()));
 }
예제 #7
0
 /**
  * @return int
  */
 public function QuantityAvailable()
 {
     return $this->accessory->GetQuantityAvailable();
 }