Esempio n. 1
0
 public function testCreate()
 {
     $basketFactory = new Basket\Factory\BasketFactory(self::BASKET_NAME_TEST, 10);
     $basket = $basketFactory->getBasket();
     $this->assertInstanceOf(Basket\Entity\Basket::class, $basket);
     return $basket;
 }
 public function testBasketWithBalls()
 {
     $basketFactory = new Basket\Factory\BasketFactory('Test', 2);
     $basket = $basketFactory->getBasket();
     $numbers = array(1, 2);
     $provider = new Balls\Provider\CustomBallsProvider($numbers);
     $provider->setNumbers($numbers);
     $basketFactory->loadBalls($provider, new Balls\Factory\BallFactory());
     $this->assertEquals($numbers, $basket->getBalls()->toArray());
 }
Esempio n. 3
0
        $basketFactory = new Basket\Factory\BasketFactory('#' . $i, 10);
        $basketFactory->loadBalls($provider, new Balls\Factory\BallFactory());
        $basket = $basketFactory->getBasket();
        $baskets->addBasket($basket);
        echo 'Basket ' . (string) $basket . "\n";
    }
});
/**
 * Create User's basket and fill it from input
 */
$scenario->addCommand(function ($registry) {
    $provider = new PlayBalls\UserBallsProvider(function () {
        echo 'Please insert your bills numbers separated by comma and press enter: ' . "\n";
        return readline();
    });
    $basketFactory = new Basket\Factory\BasketFactory('User\'s Basket', 100);
    $basketFactory->loadBalls($provider, new Balls\Factory\BallFactory());
    $basket = $basketFactory->getBasket();
    $registry->setUserBasket($basket);
    echo (string) $basket . "\n";
});
/**
 * Find answer to B - baskets, that have only balls owned by the user
 */
$scenario->addCommand(function ($registry) {
    if (!($userBasket = $registry->getUserBasket())) {
        return;
    }
    $query = new Basket\Query\BasketQuery(array(new PlayBalls\OnlyOwnedBallsCriteria($userBasket->getBalls())));
    $result = $query->fetchAll($registry->getBaskets());
    echo 'Answer to B: ' . (string) $result . "\n";